A paragraph in HTML is defined using the <p>
tag. Every time you use this tag, the text starts from a new line.
This is the first paragraph on the page.
This is the second paragraph that comes right after.
HTML doesn't care about how many spaces or new lines you add in your code. It will always display the text in a single block unless told otherwise.
This paragraph is written across many lines and has lots of spaces, but HTML will still render it as one line.
You can separate content using a horizontal rule with the <hr>
tag.
This is some intro text.
Here comes the detailed explanation.
<hr>
tag is self-closing and doesn't need a closing tag.
Sometimes, you just want to break the line without starting a whole new paragraph. Use the <br>
tag for that:
This is
a sentence
with line breaks.
<hr>
, the <br>
tag is also self-closing.
If you want to keep the exact spacing and line breaks as written, use the <pre>
tag:
My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me.
<pre>
tag is perfect for poems, song lyrics, or displaying raw code.