HTML Text Formatting and Elements

6.1 Headings in HTML

Headings are used to define titles and subtitles on a webpage. They range from <h1> (most important) to <h6> (least important).

Example:

html
1<h1>Main Heading</h1> 2<h2>Sub Heading</h2> 3<h3>Smaller Sub Heading</h3>

6.2 Paragraphs and Line Breaks

<p>: Defines a paragraph.
<br>: Creates a line break.
<hr>: Inserts a horizontal line (thematic break).

Example:

html
1<p>This is a paragraph of text.</p> 2<p>This is another paragraph.</p> 3<br> 4<hr> 5<p>New section starts here.</p>

6.3 Text Formatting Tags

HTML provides inline elements to style text.

TagMeaningExample
<b>Bold (non-semantic)<b>Bold text</b>
<strong>Important (semantic)<strong>Important!</strong>
<i>Italic (non-semantic)<i>Italic text</i>
<em>Emphasized text (semantic)<em>Emphasized!</em>
<u>Underline<u>Underlined</u>
<mark>Highlight text<mark>Highlighted</mark>
<small>Smaller text<small>Fine print</small>
<del>Deleted text<del>Old price</del>
<ins>Inserted text<ins>New price</ins>
<sub>SubscriptH<sub>2</sub>O
<sup>SuperscriptX<sup>2</sup>

6.4 Key Takeaways

<h1> should usually be used once per page for SEO and clarity.
• Use headings to create a logical structure, not just for styling.
• Search engines give higher importance to <h1> compared to <h6>.
• Use <p> for blocks of text, not just <br>.
<br> is useful for poetry, addresses, or cases where spacing matters.
<hr> represents a thematic break or section change.
• Prefer semantic tags (<strong>, <em>) for better SEO and accessibility.
• Use <mark> for highlighting search results or key terms.
<sub> and <sup> are mainly used in formulas, footnotes, or chemical notations.