HTML Paragraphs and Line Breaks
Learn how to write paragraphs in HTML, how browsers handle whitespace, and when to use br or pre.
Write paragraphs
The <p> element groups a paragraph of text. Use a new paragraph when the content moves to a new thought or topic.
<p>HTML describes the structure of a web page.</p>
<p>CSS controls how that content looks.</p>
Whitespace in HTML
Browsers normally collapse runs of spaces and line breaks in HTML source into a single space in rendered text. Use CSS for layout and spacing rather than adding many spaces or non-breaking spaces.
Use line breaks for a real line break
The <br> element creates a line break within a block of text, such as the lines of a postal address or a poem. Do not use repeated <br> elements to create paragraph spacing.
<p>HTMLCSSCODING<br>
123 Web Street<br>
Example City</p>
Show preformatted text
The <pre> element preserves spaces and line breaks in its content. It is useful for text where that spacing is meaningful, such as code examples.
<pre>
first line
indented line
</pre>