Paragraphs

HTML Paragraphs

Example

The <p> element defines a paragraph. Browsers add space before and after each paragraph:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

</body>
</html>

Result

Display: Spaces and Line Breaks

Example

Browsers collapse extra spaces and line breaks in the HTML into a single space:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>

<p>
This paragraph
contains      a lot of spaces
in the source code,
but the browser ignores them.
</p>

</body>
</html>

Result

Line Breaks, Rules and Preformatted Text

Example

<br> breaks a line, <hr> draws a thematic break, and <pre> keeps spaces and line breaks exactly as written:

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
</head>
<body>

<p>Roses are red,<br>violets are blue.</p>
<hr>
<pre>
  Name      Score
  Asha      92
  Vikram    87
</pre>

</body>
</html>

Result