Paragraphs
Developers place almost all non-heading text within a paragraph element in a web document. The <p>
tags define paragraph elements. Remember paragraph elements are two-tag elements written as <p>...</p>
.
<p>This is a paragraph element.</p>
Compare this to Markdown:
This is a paragraph.
In Markdown, a paragraph requires no extra markup to signify it as such. An empty line between text blocks represents a new paragraph.
Any text between the paragraph tags <p>...</p>
belongs to the same paragraph. Putting text between paragraph tags is the most common way of writing paragraphs in HTML pages.
You’ll notice that when using Markdown, empty lines create paragraphs and provide a cushion between one paragraph and the next. HTML does not do this.
With HTML, paragraphs tags create paragraphs, and browsers automatically add cushion above and below paragraph elements.
By default, browsers remove empty spaces from paragraph element blocks. Browsers mimic this behavior with spaces and extra blank lines too. You need to be aware that you cannot change the output of your rendered HTML code by adding additional spaces or lines unless you code for them; merely pressing the space bar or return does not result in a new space or newline.
You can see this below, where the first several paragraphs display as single lines. Using the line break, or the <br />
tag moves the cursor to the next line within the paragraph element.
You can use the preformatted text element (<pre>...</pre>
) to tell a browser to render spaces and text exactly as you’ve typed.
The <pre>
tag usually displays the contents between the element in a fixed-width font, typically used for preformatted code or text.
html
- Previous
- Next