On this page11 sections
  1. Learning Objectives
  2. 1. Important and Emphasised Text
  3. 2. Highlights, Changes and Small Print
  4. 3. Subscript and Superscript
  5. 4. Code and Keyboard Keys
  6. 5. Quotations
  7. 6. Comments
  8. Common Beginner Mistakes
  9. Practice Questions
  10. Practice Answers
  11. Key Takeaways

Lecture 007: Formatting, Quotations & Comments

Category2: Text & Styles
Lecture007 of 048
Estimated video length12 min
TargetHTML5 · any modern browser
LevelBeginner

Inside a paragraph you'll often want to stress a word, show a price that was cut, or mark a keyboard shortcut. HTML has a small element for each of these. Comments let you leave notes in your code that visitors never see.


Learning Objectives

  • Mark important and emphasised text with <strong> and <em>
  • Use <mark>, <del>, <ins>, <small>, <sub>, <sup>, <code> and <kbd>
  • Quote text with <blockquote> and <q>
  • Write HTML comments

1. Important and Emphasised Text

ElementMeaningDefault look
<strong>Importantbold
<em>Stressed, as you'd say it alouditalic

Example

html
<p><strong>Warning:</strong> the oven is hot.</p>
<p>I said I wanted <em>tea</em>, not coffee.</p>

You may also see <b> and <i>. They only change the look and carry no meaning. Prefer <strong> and <em>, because screen readers can announce them.


2. Highlights, Changes and Small Print

Example

html
<p>Search results for <mark>biryani</mark>.</p>
<p>Price: <del>Rs 1,500</del> <ins>Rs 1,200</ins></p>
<p><small>Prices include 16% sales tax.</small></p>
  • <mark>: highlighted text, like a highlighter pen
  • <del> / <ins>: text that was removed / added
  • <small>: side comments and fine print

3. Subscript and Superscript

Example

html
<p>Water is H<sub>2</sub>O.</p>
<p>The area is 25 m<sup>2</sup>.</p>

4. Code and Keyboard Keys

Example

html
<p>Use the <code>&lt;p&gt;</code> element for paragraphs.</p>
<p>Save the file with <kbd>Ctrl</kbd> + <kbd>S</kbd>.</p>

&lt; and &gt; are entities: codes for < and >. Without them, the browser would treat <p> as a real tag. Other useful ones are &amp; (&) and &copy; (©).


5. Quotations

<blockquote> holds a long quote as its own block. <q> holds a short quote inside a sentence, and the browser adds the quote marks.

Example

html
<blockquote>
  The best way to learn to code is to write code every day.
</blockquote>
<p>My teacher always says <q>practice beats talent</q>.</p>

6. Comments

A comment starts with <!-- and ends with -->. The browser ignores it completely.

Example

html
<!-- Main title of the page -->
<h1>Our Menu</h1>

<!-- Desserts are coming next week
<h2>Desserts</h2>
-->
<p>Fresh food, every day.</p>

Use comments to explain tricky parts, or to switch a piece of HTML off for a while. Comments are visible in View Page Source, so never put passwords in them.


Common Beginner Mistakes

1. Using <strong> just to make things bold. If the text isn't actually important, it's a styling job for CSS.

2. Typing < in text. <p>Use <p> tags</p> breaks. Write &lt;p&gt;.

3. Unclosed comments. Forget --> and everything after it disappears from the page.

4. Secrets in comments. Anyone can read them with View Page Source.


Practice Questions

  1. Which element marks text as important: <b> or <strong>?
  2. Show an old price of Rs 900 crossed out and a new price of Rs 700.
  3. Write CO₂ using HTML.
  4. How do you display the text <h1> on a page without the browser treating it as a tag?
  5. Which element would you use for a famous quote that sits on its own?
  6. Write a comment that says "footer starts here".

Practice Answers

  1. <strong>. It carries meaning; <b> only changes the look.
  2. <p><del>Rs 900</del> <ins>Rs 700</ins></p>
  3. CO<sub>2</sub>
  4. Use entities: &lt;h1&gt;
  5. <blockquote>
  6. <!-- footer starts here -->

Key Takeaways

  • <strong> = important, <em> = stressed; prefer them over <b> and <i>.
  • <mark>, <del>, <ins>, <small>, <sub>, <sup>, <code>, <kbd> each have one clear job.
  • Use entities such as &lt; and &amp; for special characters.
  • <!-- comments --> are invisible on the page but visible in the source.