Paragraphs & Text Formatting
Master the art of text content with paragraphs, line breaks, and semantic text formatting elements for professional, accessible web pages.
The Paragraph Element
The <p> element defines a paragraph of text. It's one of the most commonly used HTML elements for body content.
<p>This is a paragraph of text. Browsers automatically add spacing before and after paragraphs.</p>
<p>This is another paragraph. Each paragraph is a separate block element.</p>
<p>Paragraphs can contain <strong>bold text</strong>, <em>italic text</em>, and <a href="#">links</a>.</p>Line Breaks: <br> vs. <p>
Understanding when to use <br> (line break) versus <p> (new paragraph) is crucial for semantic HTML.
When to Use Each:
| Element | Purpose | Use Cases |
|---|---|---|
<p> | Separate paragraphs | Body text, distinct ideas, spacing between blocks |
<br> | Line break within content | Poems, addresses, lyrics, single lines within a paragraph |
<p>
Roses are red,<br>
Violets are blue,<br>
HTML is awesome,<br>
And so are you!
</p><p>
John Doe<br>
123 Main Street<br>
New York, NY 10001<br>
United States
</p><p>First paragraph</p>
<br><br><br> <!-- Wrong! Use CSS margin instead -->
<p>Second paragraph</p><p>First paragraph</p>
<p style="margin-top: 2rem;">Second paragraph with extra spacing</p>
<!-- Or better yet, use a CSS class -->
<p>First paragraph</p>
<p class="spaced-paragraph">Second paragraph</p>
<style>
.spaced-paragraph {
margin-top: 2rem;
}
</style><br> tags in a row, you should probably be using paragraphs or CSS spacing instead.Semantic Text Formatting Elements
HTML provides semantic elements that convey meaning along with formatting. Always prefer these over purely visual elements.
Emphasis Elements
<strong> - Strong Importance
Renders as: Bold text
Meaning: Indicates strong importance, seriousness, or urgency
<p><strong>Warning:</strong> This action cannot be undone.</p>
<p>The <strong>most important</strong> thing to remember is...</p><em> - Emphasis
Renders as: Italic text
Meaning: Stresses emphasis, changes meaning of sentence
<p>I <em>love</em> HTML!</p>
<p>We <em>must</em> finish this today.</p><b> - Bring Attention To
Renders as: Bold text (but without semantic importance)
Meaning: Draw attention without conveying extra importance
<p>The <b>product name</b> is displayed in bold.</p>
<p><b>Keywords:</b> HTML, CSS, JavaScript</p><i> - Alternate Voice
Renders as: Italic text (but without emphasis)
Meaning: Technical terms, foreign phrases, thoughts
<p>The French phrase <i>je ne sais quoi</i> is hard to translate.</p>
<p><i>Homo sapiens</i> is the scientific name for humans.</p>Which Element Should I Use?
| Scenario | Use This | Not This |
|---|---|---|
| Important information | <strong> | <b> |
| Stress emphasis | <em> | <i> |
| Product names, keywords | <b> | <strong> |
| Foreign words, scientific names | <i> | <em> |
Other Text Formatting Elements
<mark> - Highlighted Text
Renders as: Highlighted text
Use for: Search results, relevant references
<p>Search results for "<mark>HTML tutorial</mark>"</p><small> - Fine Print
Renders as: Smaller text
Use for: Side comments, disclaimers, legal text
<p>Price: $99 <small>(tax not included)</small></p>
<p><small>Terms and conditions apply.</small></p><del> and <ins> - Edits
Renders as: Deleted text and Inserted text
Use for: Document revisions, showing changes
<p>Price: <del>$199</del> <ins>$149</ins> (25% off!)</p>
<p>Meeting time: <del{">"} 3 PM</del> <ins>4 PM</ins></p><s> - Strikethrough
Renders as: Strikethrough text
Use for: No longer accurate or relevant
<p><s>Out of stock</s> Now available!</p><u> - Underline
Renders as: Underlined text
Use for: Misspelled words, proper names (Chinese)
<p>Please correct the <u>speling</u> error.</p><sub> and <sup> - Subscript & Superscript
Renders as: H2O and x2
Use for: Chemical formulas, mathematical expressions, footnotes
<p>The formula for water is H<sub>2</sub>O.</p>
<p>E = mc<sup>2</sup></p>
<p>Referenced in footnote<sup>1</sup></p>Code and Technical Text
<code> - Inline Code
Renders as: monospaced code
Use for: Variable names, function names, short code snippets
<p>Use the <code>console.log()</code> function to print output.</p>
<p>The <code>background-color</code> CSS property sets the background.</p><pre> - Preformatted Text
Purpose: Preserves whitespace and line breaks
<pre>
function greet(name) {
console.log("Hello, " + name);
}
</pre>Renders exactly as written:
function greet(name) {
console.log("Hello, " + name);
}<kbd> - Keyboard Input
Renders as: Ctrl + C
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.</p>
<p>Type <kbd>npm install</kbd> to install packages.</p><samp> - Sample Output
Purpose: Represents output from a program
<p>The command returned: <samp>Error: File not found</samp></p><var> - Variable
Purpose: Represents a mathematical or programming variable
<p>The formula is <var>a</var><sup>2</sup> + <var>b</var><sup>2</sup> = <var>c</var><sup>2</sup></p>
<p>Set <var>x</var> = 10 and <var>y</var> = 20</p>Quotations and Citations
<blockquote> - Block Quotation
Purpose: Long quotations (separate paragraph)
<blockquote cite="https://example.com/article">
<p>The only way to do great work is to love what you do.</p>
<footer>— <cite>Steve Jobs</cite></footer>
</blockquote>The only way to do great work is to love what you do.
<q> - Inline Quotation
Purpose: Short quotes within a paragraph
<p>As Einstein said, <q>Imagination is more important than knowledge.</q></p>Renders as: As Einstein said, Imagination is more important than knowledge.
<cite> - Citation
Purpose: Reference to a creative work
<p>My favorite book is <cite>The Great Gatsby</cite> by F. Scott Fitzgerald.</p>
<p>Read more in <cite>HTML: The Definitive Guide</cite>.</p><abbr> - Abbreviation
Purpose: Abbreviations and acronyms with tooltips
<p>Use <abbr title="HyperText Markup Language">HTML</abbr> to structure content.</p>
<p>The <abbr title="World Wide Web Consortium">W3C</abbr> maintains web standards.</p>Renders as: Use HTML to structure content.
Best Practices Summary
✅ Do
- Use
<p>for paragraphs,<br>for line breaks - Choose semantic elements (
<strong>,<em>) - Use
<abbr>with titles for abbreviations - Use
<code>for inline code references - Cite sources with
<cite> - Keep paragraphs concise (3-5 sentences)
⌠Don't
- Use multiple
<br>for spacing (use CSS) - Use
<b>/<i>when you mean importance/emphasis - Underline text that isn't a link
- Write huge walls of text (break into paragraphs)
- Use deprecated elements like
<font>,<center>