user18208338
user18208338

Reputation:

Can I use <pre> tag in any context I want linebreaks display?

I'm looking up HTML text format on MDN and I came across with the example below:

<address>
  <p>
    Chris Mills<br />
    Manchester<br />
    The Grim North<br />
    UK
  </p>

  <ul>
    <li>Tel: 01234 567 890</li>
    <li>Email: [email protected]</li>
  </ul>
</address>

So, Instead of using the <br/> tag to separate the <p> content, can I use the <pre> tag? Further than that, can I use it in any context I want some linebreaks?

Upvotes: 0

Views: 194

Answers (2)

Prashant Balotra
Prashant Balotra

Reputation: 88

There is a CSS way you can retain literal newlines and whitespace.

white-space: pre-wrap;

enter image description here

For more information, you can refer here.

Upvotes: 0

user19866794
user19866794

Reputation:

The <pre> tag cannot be used.

This is because <pre> defines if it is shown exactly like what is written in your source code, in monospace, and that it is pre-formatted text. Just like the comment above, you can use CSS white space.

Upvotes: -1

Related Questions