Section 4: Headings, Paragraphs, Text Formatting and Quotations
Welcome to Section 4 of Codementrix HTML5 Mastery. In this lesson, you will learn how to organize page content using headings and paragraphs, emphasize important information, represent inserted or deleted text, and display quotations correctly. You will also understand the difference between semantic HTML and purely visual formatting.
1. Learning Objectives
By the end of this lesson, you will be able to:
- Use all six HTML heading levels correctly.
- Structure content with headings and paragraphs.
- Understand the difference between visual appearance and semantic meaning.
- Use bold, italic, emphasized, highlighted, and other text-formatting elements appropriately.
- Represent inline and block quotations using the correct elements.
- Display abbreviations, definitions, citations, and computer-related text where appropriate.
- Use line breaks, thematic breaks, and preformatted text correctly.
- Avoid common HTML text-formatting and document-structure mistakes.
2. HTML Headings: Organizing Content
HTML provides six heading elements, from <h1> through <h6>. They communicate the heading structure of a page.
<h1>— the highest heading level.<h2>— a second-level heading.<h3>— a third-level heading.<h4>— a fourth-level heading.<h5>— a fifth-level heading.<h6>— the lowest heading level.
Example: Six Heading Levels
<h1>HTML5 Mastery</h1>
<h2>HTML Fundamentals</h2>
<h3>Text Elements</h3>
<h4>Paragraphs</h4>
<h5>Paragraph Examples</h5>
<h6>Additional Notes</h6>
Browsers normally display these headings at different default sizes and weights. However, their primary purpose is to communicate the structure of the content, not simply to make text look large or small.
Choosing the Correct Heading Level
Choose a heading based on the relationship between sections, rather than its default font size.
<h1>Web Development Course</h1>
<h2>HTML</h2>
<p>Learn the structure of web pages.</p>
<h3>HTML Text Elements</h3>
<p>Learn headings, paragraphs and emphasis.</p>
<h3>HTML Forms</h3>
<p>Learn how to collect user input.</p>
<h2>CSS</h2>
<p>Learn how to style web pages.</p>
The structure is:
- Web Development Course — main page heading.
- HTML and CSS — major sections.
- HTML Text Elements and HTML Forms — subsections of HTML.
Best Practices for Headings
- Use headings to describe the content that follows.
- Maintain a logical hierarchy wherever possible.
- Do not choose a heading level only because its default appearance is convenient.
- Do not use headings merely to make ordinary text bold or large.
- Use CSS to customize heading size, color, spacing, and typography.
- Do not assume every web page must contain exactly one
<h1>because of a rigid SEO rule. Use a clear, meaningful heading structure appropriate to the page.
Accessibility tip: Screen-reader users can navigate by headings. Meaningful headings and a logical hierarchy help users understand and move through long pages.
3. Paragraphs: Writing Readable Content
The <p> element represents a paragraph. It is suitable for ordinary prose, descriptions, introductions, explanations, and other paragraph-like content.
Basic Syntax
<p>This is a paragraph.</p>
Multiple Paragraphs
<h2>About Codementrix</h2>
<p>Codementrix shares practical programming tutorials
and web development learning resources.</p>
<p>Learners can explore HTML, CSS, JavaScript,
PHP, Laravel and other technologies.</p>
Browsers usually display paragraphs as separate blocks with default spacing. The exact spacing and appearance can be changed with CSS.
Does a New Line in the Source Create a New Paragraph?
No. A line break in your source code does not automatically create a new HTML paragraph.
<p>
Learn HTML
with Codementrix.
</p>
In ordinary HTML rendering, the text will generally appear as “Learn HTML with Codementrix.” Consecutive whitespace characters are usually collapsed.
To create two paragraphs, use two paragraph elements:
<p>Learn HTML.</p>
<p>Practice HTML every day.</p>
Important Paragraph Rules
- A paragraph can contain text and phrasing content, such as
<strong>,<em>, and<a>. - A paragraph must not contain arbitrary flow containers such as a
<div>or another paragraph. - Browsers may automatically close a paragraph when they encounter certain elements that cannot appear inside it.
- Use CSS for visual spacing rather than inserting empty paragraphs repeatedly.
Incorrect:
<p>
Our services
<div>Web development</div>
</p>
Better:
<p>Our services include:</p>
<div>Web development</div>
4. Bold Text: Strong Importance vs Visual Boldness
HTML provides two commonly used elements for text that appears bold: <strong> and <b>. They have different meanings.
The Strong Element
Use <strong> when the text has strong importance, seriousness, or urgency in context.
<p><strong>Warning:</strong> Save your work before closing the editor.</p>
<p><strong>Important:</strong> Never share your password.</p>
Browsers usually display strong text in bold. Its semantic importance is the key distinction.
The B Element
Use <b> when you want to draw attention to text without implying that it has greater importance, such as a keyword or product name in a passage.
<p>The term <b>HTML</b> stands for HyperText Markup Language.</p>
Remember: Use <strong> for importance and <b> for attention without added importance. Do not choose an element based only on its default appearance.
5. Italics: Emphasis vs Alternative Voice
The <em> and <i> elements are often displayed in italics, but their meanings differ.
The Em Element
Use <em> when you want to emphasize a word or phrase. The emphasis can change how a sentence is understood.
<p>You should <em>always</em> back up important files.</p>
Emphasis can be nested to represent stronger stress emphasis, although it should be used naturally rather than simply to obtain more italic styling.
The I Element
Use <i> for text in an alternate voice or mood, or for terms conventionally distinguished from the surrounding prose, such as a technical term or a word from another language.
<p>The Latin phrase <i lang="la">carpe diem</i> means to seize the day.</p>
<p>The term <i>cache</i> is common in web development.</p>
The lang="la" attribute identifies the language of the Latin phrase.
Quick Comparison
<em>— stress emphasis.<i>— alternate voice, mood, or conventionally distinguished text.<strong>— strong importance or urgency.<b>— attention without implying extra importance.
6. Highlighted, Smaller and Superscript or Subscript Text
The Mark Element
Use <mark> for text highlighted because it is relevant in the current context, such as a matching search result.
<p>Search result: Learn <mark>HTML attributes</mark> in this lesson.</p>
Browsers usually render marked text with a highlighted background. CSS can change its appearance.
The Small Element
Use <small> for side comments, fine print, disclaimers, or similar content.
<p>Course price: ₹499</p>
<p><small>Prices may change without notice.</small></p>
<small> is not intended as a general-purpose tool for making any text smaller. Use CSS when the only goal is changing font size.
Superscript: The Sup Element
Use <sup> for superscript text, such as exponents or certain footnote markers.
<p>Mathematics: x<sup>2</sup> + y<sup>2</sup> = z<sup>2</sup></p>
<p>This claim needs a source.<sup>1</sup></p>
Subscript: The Sub Element
Use <sub> for subscript text, such as chemical formulas.
<p>Water: H<sub>2</sub>O</p>
<p>Carbon dioxide: CO<sub>2</sub></p>
Use these elements for text that genuinely has superscript or subscript meaning. Do not use them simply to adjust the visual position of ordinary text.
7. Inserted, Deleted and Underlined Text
The Ins Element
The <ins> element represents text that has been inserted into a document.
<p>Course fee:
<del>₹999</del>
<ins>₹499</ins>
</p>
The Del Element
The <del> element represents text that has been deleted from a document.
Browsers commonly display deleted text with a strikethrough and inserted text with an underline, but the elements convey editorial meaning, not merely visual styling.
The U Element
The <u> element represents a non-textual annotation, such as a proper name that needs a specific annotation or a misspelled word in an editing interface. It is not intended as a generic underline tool.
<p>The document contains a
<u>missspelled</u> word.
</p>
If you only want underlined styling, use CSS. Underlines can be mistaken for links, so use them carefully.
Practical Example: Showing a Price Change
<p>
Previous price:
<del>₹1,499</del>
</p>
<p>
Current price:
<ins>₹999</ins>
</p>
This is more meaningful than using a strikethrough style without identifying the old and new content semantically.
8. Line Breaks and Thematic Breaks
The Br Element
The <br> element creates a line break within text when a line break is part of the content.
<p>
Codementrix<br>
Bhubaneswar, Odisha<br>
India
</p>
This is appropriate for content such as postal addresses or poetry where the line divisions are meaningful.
Do not use many <br> elements to create vertical spacing between paragraphs or page sections. Use separate elements and CSS margins instead.
The Hr Element
The <hr> element represents a thematic break between paragraphs or sections, such as a change of topic.
<p>This section explains HTML headings.</p>
<hr>
<p>The next section explains text emphasis.</p>
Browsers commonly display a horizontal line for an hr element, but its meaning is a thematic change, not simply a decorative line. For decoration alone, CSS borders are usually more appropriate.
9. Quotations: Blockquote and Q
HTML provides distinct elements for quotations depending on whether the quotation is presented as a separate block or within a sentence.
The Blockquote Element
Use <blockquote> for an extended quotation that is presented as a separate block of content.
<blockquote cite="https://example.com/learning">
<p>Learning becomes more effective when knowledge is
combined with regular practice.</p>
</blockquote>
<p>Source: Example learning resource.</p>
The cite attribute can contain the URL of the source of the quotation. It does not automatically display a citation or source link to users. If you want readers to see the source, provide a visible citation or link in the content.
Do not use a blockquote simply to indent ordinary text. Use it when the content is genuinely quoted from another source.
The Q Element
Use <q> for a short inline quotation within a paragraph.
<p>The instructor said,
<q>Practice a little every day.</q>
</p>
Browsers commonly insert quotation marks around q content automatically. The exact quotation marks can depend on the language and browser styling. Do not add duplicate quotation marks without considering the browser's behavior.
Blockquote vs Q
<blockquote>— an extended quotation presented as a separate block.<q>— a short inline quotation.
For a visible source, you can add a citation outside the quotation:
<blockquote cite="https://example.com/article">
<p>Example quotation from the article.</p>
</blockquote>
<p>Source:
<a href="https://example.com/article">Read the original article</a>
</p>
Only present text as a quotation when you have a legitimate source and permission or another valid basis to use it. Attribute quotations accurately.
10. Abbreviations, Definitions and Citations
The Abbr Element
Use <abbr> to identify an abbreviation or acronym. The optional title attribute can provide its expanded form.
<p>
<abbr title="HyperText Markup Language">HTML</abbr>
structures web content.
</p>
Some browsers may show the title as a tooltip. Do not rely on a tooltip as the only way to provide essential information, particularly for touch and keyboard users.
The Dfn Element
Use <dfn> to mark the defining instance of a term in a definition.
<p>
<dfn>HTML</dfn> is the standard markup language
used to structure content on the web.
</p>
The surrounding text provides the definition. The dfn element identifies the term being defined; it does not automatically create a dictionary entry.
The Cite Element
Use <cite> for the title of a creative work, such as a book, film, song, or research paper.
<p>I am reading <cite>The Pragmatic Programmer</cite>.</p>
Do not use <cite> simply to identify a person's name as the author of a quotation. It is intended for the title of a work.
Combining These Elements
<p>
<abbr title="HyperText Markup Language">HTML</abbr>
is discussed in the book
<cite>HTML and CSS: Design and Build Websites</cite>.
</p>
The example identifies the abbreviation and the title of a book. Always ensure the content and attribution accurately reflect the real source.
11. Code, Keyboard Input and Sample Output
When writing technical tutorials, choose elements that distinguish source code, user input, and program output.
The Code Element
Use <code> for a fragment of computer code.
<p>Use <code>console.log()</code> to print a value in JavaScript.</p>
The Kbd Element
Use <kbd> to represent keyboard input, such as a key or key combination.
<p>Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save on many Windows applications.</p>
Keyboard shortcuts may vary by operating system and application. Explain the appropriate shortcut for your audience.
The Samp Element
Use <samp> for sample output from a computer program.
<p>Program output:
<samp>File saved successfully.</samp>
</p>
The Pre Element
Use <pre> when whitespace and line breaks should be preserved as preformatted text.
<pre>
Name: Bikram
Role: Developer
Location: Odisha
</pre>
The browser normally preserves whitespace and line breaks inside preformatted text. It is commonly combined with code when presenting a multi-line code sample.
<pre><code>function greet() {
console.log("Hello, Codementrix!");
}</code></pre>
In a real HTML source file, escape characters such as < and > when you need to display HTML tags as text rather than have the browser interpret them as markup.
12. Complete Working Example: A Technical Blog Article
The following example combines headings, paragraphs, emphasis, quotations, abbreviations, citations, and code-related text in a realistic article.
<article>
<h1>Why Learn HTML?</h1>
<p>
<abbr title="HyperText Markup Language">HTML</abbr>
is essential for structuring content on the web.
</p>
<h2>Start with the Basics</h2>
<p>
Learn the meaning of <strong>elements</strong>,
attributes, headings and paragraphs before moving
to advanced topics.
</p>
<h2>Practice Regularly</h2>
<p>
You should <em>practice every day</em> to improve
your understanding of web development.
</p>
<blockquote>
<p>Small, consistent steps can build strong skills.</p>
</blockquote>
<h2>Try an Example</h2>
<p>Create a paragraph using the <code>p</code> element.</p>
<pre><code><p>Hello, world!</p></code></pre>
<p>
Learn more from
<cite>HTML Living Standard</cite>
and other reliable technical references.
</p>
</article>
This example uses semantic elements to describe the purpose of the content. It does not depend on visual styling alone to communicate the structure.
13. Common Mistakes and How to Avoid Them
Mistake 1: Using Headings Only for Font Size
Incorrect approach: using an h1 because you want large text, even when the text is not a heading.
Better approach: use the correct semantic element and customize its appearance with CSS.
Mistake 2: Skipping Heading Levels Without a Reason
Example:
<h2>HTML Topics</h2>
<h5>Paragraphs</h5>
This creates a confusing hierarchy if Paragraphs is intended as a direct subsection of HTML Topics. Use an h3 in that case. The goal is a meaningful outline, not a strict prohibition against every skipped level in every situation.
Mistake 3: Using BR Elements for Spacing
Incorrect:
<p>First paragraph.</p>
<br><br><br>
<p>Second paragraph.</p>
Better:
<p>First paragraph.</p>
<p>Second paragraph.</p>
Use CSS margins to control spacing.
Mistake 4: Choosing B Instead of Strong for Important Warnings
If a message is genuinely important, use <strong>. Do not rely only on bold appearance to convey meaning.
Mistake 5: Choosing I Instead of Em for Stress Emphasis
Use <em> when the emphasis affects how a phrase should be understood. Use <i> when the content is in an alternate voice or conventionally distinguished.
Mistake 6: Using Blockquote for Indentation
A blockquote is for quoted content, not for ordinary content that needs to move to the right. Use CSS for indentation or layout.
Mistake 7: Adding Duplicate Quotation Marks
The browser generally renders quotation marks for a q element. Avoid adding extra quotation marks unless the desired result and language-specific behavior have been considered.
Mistake 8: Using Cite for a Person's Name
The cite element identifies the title of a creative work, not simply the person who wrote or said something. Use ordinary text or an appropriate element for the person's name.
Mistake 9: Using Empty Paragraphs to Create Space
Empty paragraphs should not be used as layout tools. Use CSS margin and padding to manage visual spacing.
14. Practical Exercises
Exercise 1: Build a Heading Hierarchy
Create a page about web development with:
- One main heading for the page title.
- Two second-level headings for HTML and CSS.
- Two third-level headings under HTML.
- At least one paragraph under each section.
Exercise 2: Format a Warning
Write a paragraph containing a warning label, an important instruction, and a word that should receive stress emphasis. Use <strong> and <em> where appropriate.
Exercise 3: Create a Quotation
Create a paragraph containing a short inline quotation using <q>. Then add a separate block quotation using <blockquote>. Include a visible source link when a real source is available.
Exercise 4: Create a Technical Explanation
Write a short paragraph that includes:
- An abbreviation with an expansion.
- A technical term identified using
<dfn>. - A code fragment using
<code>. - A keyboard shortcut using
<kbd>.
Exercise 5: Review and Improve a Blog Post
Take an existing blog article and check whether its headings describe the content, its paragraphs are properly separated, and its emphasis and quotations use appropriate elements. Replace repeated line breaks and empty paragraphs with proper structure and CSS where needed.
15. Quiz: Headings, Paragraphs, Text Formatting and Quotations
Answer the following 10 questions. Each question includes four options, the correct answer, and explanations for every option. Select your answer mentally before expanding the explanation.
Suggested score: 8/10 or higher. The expandable answers below reveal the correct answer but do not automatically score or save learner progress without additional quiz functionality.
Question 1: Which element represents the highest heading level in HTML?
<h6><head><h1><heading>
Show correct answer and explanations
Correct answer: C — <h1>
- A — Incorrect: h6 is the lowest of the six heading levels.
- B — Incorrect: head contains document metadata and resource information; it is not a heading element.
- C — Correct: h1 is the highest heading level.
- D — Incorrect: heading is not a standard HTML heading element.
Question 2: What is the primary purpose of an HTML heading?
- To make text large in every browser
- To communicate the structure and hierarchy of content
- To insert a line break
- To create a hyperlink
Show correct answer and explanations
Correct answer: B
- A — Incorrect: Headings have default styles, but their main purpose is structural and semantic.
- B — Correct: Headings organize content and help readers and assistive technologies understand its hierarchy.
- C — Incorrect: br creates a line break.
- D — Incorrect: a creates a hyperlink when appropriately configured.
Question 3: Which element is best for a paragraph of ordinary prose?
<p><br><hr><sup>
Show correct answer and explanations
Correct answer: A — <p>
- A — Correct: p represents a paragraph.
- B — Incorrect: br creates a line break within content.
- C — Incorrect: hr represents a thematic break.
- D — Incorrect: sup represents superscript text.
Question 4: Which element should you normally use for a genuinely important warning?
<i><strong><small><sub>
Show correct answer and explanations
Correct answer: B — <strong>
- A — Incorrect: i represents text in an alternate voice or conventionally distinguished text.
- B — Correct: strong communicates strong importance, seriousness, or urgency.
- C — Incorrect: small is intended for side comments and fine print, among other similar content.
- D — Incorrect: sub represents subscript text.
Question 5: What is the difference between em and i?
- They always mean exactly the same thing
- em represents stress emphasis; i represents an alternate voice or conventionally distinguished text
- em creates a paragraph; i creates a heading
- i is used only for images
Show correct answer and explanations
Correct answer: B
- A — Incorrect: They may look similar by default, but their semantic meanings differ.
- B — Correct: em marks stress emphasis, while i marks text in an alternate voice or another conventionally distinguished use.
- C — Incorrect: p represents paragraphs and h1 through h6 represent headings.
- D — Incorrect: img represents an image; i is a text element.
Question 6: Which element is appropriate for a short inline quotation?
<blockquote><q><cite><dfn>
Show correct answer and explanations
Correct answer: B — <q>
- A — Incorrect: blockquote represents an extended quotation presented as a block.
- B — Correct: q is intended for short inline quotations.
- C — Incorrect: cite identifies the title of a creative work.
- D — Incorrect: dfn identifies a defining instance of a term.
Question 7: Which element represents an extended quotation?
<blockquote><mark><u><kbd>
Show correct answer and explanations
Correct answer: A — <blockquote>
- A — Correct: blockquote represents an extended quotation presented separately from surrounding text.
- B — Incorrect: mark identifies text highlighted for relevance in the current context.
- C — Incorrect: u represents text with a non-textual annotation, such as a spelling annotation.
- D — Incorrect: kbd represents keyboard input.
Question 8: Which element is appropriate for a chemical formula such as H₂O?
<sup><sub><small><strong>
Show correct answer and explanations
Correct answer: B — <sub>
- A — Incorrect: sup represents superscript, such as the 2 in x².
- B — Correct: sub represents subscript, such as the 2 in H₂O.
- C — Incorrect: small is for side comments and fine print, not chemical notation.
- D — Incorrect: strong represents importance, not subscript positioning.
Question 9: What does the cite element represent?
- Any person's name in a quotation
- The title of a creative work, such as a book or film
- A keyboard shortcut
- A highlighted search result
Show correct answer and explanations
Correct answer: B
- A — Incorrect: cite is not intended merely to mark a person's name.
- B — Correct: cite identifies the title of a creative work.
- C — Incorrect: kbd is used for keyboard input.
- D — Incorrect: mark can identify text highlighted for relevance.
Question 10: Which statement about br and hr is correct?
- Both are paragraph elements
- br creates a line break, while hr represents a thematic break
- hr creates a hyperlink, while br creates a heading
- Both must have closing tags in HTML
Show correct answer and explanations
Correct answer: B
- A — Incorrect: Neither element represents a paragraph.
- B — Correct: br creates a line break within text, and hr represents a thematic change in content.
- C — Incorrect: a creates hyperlinks and h1 through h6 create headings.
- D — Incorrect: br and hr are void elements and do not have closing tags in HTML.
16. Final Checklist
Before moving to Section 5, confirm that you can:
- Choose heading levels based on content hierarchy.
- Write separate paragraphs instead of relying on source-code line breaks.
- Distinguish strong importance from bold visual attention.
- Distinguish stress emphasis from alternate-voice text.
- Use mark, small, sup, sub, ins, del, and u appropriately.
- Use blockquote and q for quotations.
- Identify abbreviations, definitions, and creative-work titles using appropriate elements.
- Format technical examples using code, pre, kbd, and samp.
- Use br for meaningful line breaks and hr for thematic breaks.
Next section: Section 5 — Global Attributes, IDs, Classes, Data Attributes and Contenteditable.
End of Section 4 — Codementrix HTML5 Mastery.