Text is the most fundamental type of content on a webpage. In this chapter, you'll learn how HTML represents headings, paragraphs, emphasis, quotations, highlighted text, code, dates, and other text semantics.
The important idea is:
HTML should describe what text means, not just how the text looks.
HTML provides six heading levels:
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>They represent a hierarchy:
h1
│
├── h2
│ ├── h3
│ └── h3
│
└── h2
└── h3Example:
<h1>HTML Course</h1>
<h2>HTML Fundamentals</h2>
<h3>HTML Elements</h3>
<h3>HTML Attributes</h3>
<h2>HTML Forms</h2>
<h3>Input Elements</h3><h1> — Main Heading#<h1> represents the primary heading of a page or document.
Example:
<h1>My Portfolio</h1>A page might have:
<h1>My Portfolio</h1>
<p>Welcome to my portfolio.</p>Don't choose <h1> merely because you want large text.
This is incorrect thinking:
<h1> = Big text
<h2> = Slightly smaller
<h3> = SmallerInstead:
<h1> = Highest-level heading
<h2> = Section heading
<h3> = Subsection headingCSS controls the visual size.
Consider a blog:
<h1>Complete HTML Guide</h1>
<h2>HTML Basics</h2>
<h3>Elements</h3>
<h3>Attributes</h3>
<h2>HTML Forms</h2>
<h3>Input Elements</h3>
<h3>Form Validation</h3>The hierarchy becomes:
Complete HTML Guide
│
├── HTML Basics
│ ├── Elements
│ └── Attributes
│
└── HTML Forms
├── Input Elements
└── Form ValidationThis helps:
Use <p> for paragraphs.
<p>
HTML is the standard markup language used to structure
content on the web.
</p>Multiple paragraphs:
<p>
HTML defines the structure of a webpage.
</p>
<p>
CSS controls its presentation.
</p>
<p>
JavaScript adds behavior and interactivity.
</p>Don't use <div> when the content is actually a paragraph.
Prefer:
<p>This is a paragraph.</p>rather than:
<div>This is a paragraph.</div><br>#<br> creates a line break.
Example:
<p>
Anubhav<br>
India<br>
Software Developer
</p>Result:
Anubhav
India
Software DeveloperDon't use <br> repeatedly to create spacing.
❌ Bad:
<h1>My Website</h1>
<br>
<br>
<br>
<p>Hello</p>Use CSS for spacing.
<hr>#<hr> represents a thematic break between sections of content.
Example:
<h2>About Me</h2>
<p>I am a software developer.</p>
<hr>
<h2>Projects</h2>
<p>Here are my projects.</p>The browser typically displays a horizontal line.
But semantically, <hr> means more than "draw a line":
There is a thematic change or separation in the content.
<strong> vs <b>#This is important.
<strong>#Indicates that the content has strong importance, seriousness, or urgency.
<p>
<strong>Warning:</strong> Do not share your password.
</p><b>#Draws attention to text without adding the same semantic meaning of importance.
<p>
Search results for <b>HTML tutorials</b>
</p>Think:
<strong> → importance
<b> → attentionDon't use <strong> simply because you want bold styling.
CSS is better for purely visual styling.
<em> vs <i>#<em>#Represents emphasis.
<p>
You <em>must</em> complete this step.
</p>The emphasis can matter semantically.
<i>#Represents text set apart from the surrounding content for a reason such as:
Example:
<p>
The term <i>homo sapiens</i> is a scientific name.
</p>Think:
<em> → emphasis
<i> → alternate voice/technical distinction<u>#<u> represents text with a non-textual annotation or marking.
Example:
<p>
This word is <u>annotated</u>.
</p>Don't use <u> just because you want an underline.
For visual styling:
text-decoration: underline;is generally more appropriate.
<mark>#Use <mark> to indicate text that is highlighted or relevant in the current context.
<p>
You searched for:
<mark>HTML</mark>
</p>This commonly appears with a highlighted background.
Useful for:
<small>#<small> represents side comments and small print, such as:
<p>
Price: ₹999
<small>Including applicable taxes.</small>
</p>Another example:
<footer>
<small>© 2026 My Website</small>
</footer>Don't use <small> simply as a generic "make this text smaller" mechanism.
<del>#Use <del> when content has been deleted from a document.
<p>
Price:
<del>₹1999</del>
₹1499
</p>The browser normally renders the deleted text with a strikethrough.
<ins>#<ins> represents content that has been inserted.
<p>
The course contains
<del>20</del>
<ins>25</ins>
chapters.
</p>This can be useful when representing document revisions.
<sup>#Superscript places content above the normal text baseline.
Example:
<p>
10<sup>2</sup> = 100
</p>Result conceptually:
2
10Another common use:
<p>
E = mc<sup>2</sup>
</p><sub>#Subscript places content below the normal baseline.
Example:
<p>
H<sub>2</sub>O
</p>Another:
<p>
CO<sub>2</sub>
</p>Useful for:
HTML provides several elements for quotations.
<blockquote>#For a longer quotation.
<blockquote>
The journey of a thousand miles begins with one step.
</blockquote>You can provide a citation source:
<blockquote cite="https://example.com/source">
Quoted content goes here.
</blockquote>The cite attribute identifies the source URL; it doesn't automatically create a visible link.
<q>#Use <q> for a short inline quotation.
<p>
He said, <q>HTML is easy to learn.</q>
</p>Browsers commonly display quotation marks automatically.
<cite>#<cite> represents the title of a creative work or other cited work.
For example:
<p>
I am reading <cite>Clean Code</cite>.
</p>It can be used for titles of:
Don't confuse the <cite> element with the cite attribute.
<abbr>#Use <abbr> for abbreviations or acronyms.
<p>
<abbr title="HyperText Markup Language">HTML</abbr>
</p>The title provides the expanded meaning.
Another example:
<p>
<abbr title="Application Programming Interface">API</abbr>
</p>This provides useful information to users and assistive technology.
<address>#<address> represents contact information for the relevant content or document.
Example:
<address>
Anubhav Chaudhary<br>
India<br>
Email: example@example.com
</address>It is commonly used inside a footer or article.
<time>#Use <time> to represent dates and times.
Example:
<p>
The course starts on
<time datetime="2026-10-01">October 1, 2026</time>.
</p>The human-readable value:
October 1, 2026The machine-readable value:
2026-10-01This is extremely useful because machines can understand the actual date.
HTML provides elements for computer-related content.
<code>#For a short piece of code:
<p>
Use <code>console.log()</code> to print a value.
</p><pre>#Preserves whitespace and line breaks.
<pre>
Hello
World
HTML
</pre>The spacing is preserved.
Combine <pre> and <code> for a code block.
<pre><code>
function hello() {
console.log("Hello World");
}
</code></pre>This is common in:
<kbd>#<kbd> represents user input, typically keyboard input.
<p>
Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.
</p>Another example:
<p>
Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save.
</p><samp>#<samp> represents sample output from a computer program.
<p>
The program returned:
<samp>Hello World</samp>
</p><var>#<var> represents a mathematical or programming variable.
<p>
Area = <var>width</var> × <var>height</var>
</p>Another example:
<p>
x = 10
</p>could be written:
<p>
<var>x</var> = 10
</p>HTML can represent different text directions.
For example:
<p dir="rtl">
مرحبا بالعالم
</p>rtl means:
right-to-leftFor normal English:
<p dir="ltr">
Hello World
</p>When dynamically generated content may contain different languages or directions, elements such as <bdi> can help isolate text direction.
Example:
<p>
User:
<bdi>مستخدم123</bdi>
</p>This is particularly useful when mixing:
We'll revisit internationalization later.
<wbr>#<wbr> indicates a place where a browser may optionally break a long word or URL if necessary.
Example:
<p>
https://example.com/very<wbr>long<wbr>url
</p>This can help prevent long strings from causing layout problems.
This is one of the most important lessons in this chapter.
Don't think:
HTML = StylingInstead:
HTML = Meaning + Structure
CSS = Visual presentationFor example:
<strong>Important</strong>means:
This content has strong importance.
Whereas:
font-weight: bold;means:
Make this text visually bold.
These are different concepts.
Consider a product page:
<h1>MacBook Pro</h1>
<p>
The latest model features a powerful processor.
</p>
<p>
<strong>Limited offer:</strong>
Get it for <del>₹1,99,999</del> <strong>₹1,79,999</strong>.
</p>
<p>
Offer valid until
<time datetime="2026-10-15">October 15, 2026</time>.
</p>Notice how the HTML communicates meaning:
h1 → product title
p → paragraph
strong → important information
del → old price
time → dateThat's semantic HTML.
Here's a small article using many concepts from this chapter:
<article>
<h1>Learning HTML</h1>
<p>
<strong>HTML</strong> is the standard markup language
used to structure content on the web.
</p>
<hr>
<h2>Important Concept</h2>
<p>
Remember:
<mark>HTML provides structure and meaning.</mark>
</p>
<h2>Example</h2>
<pre><code>
<h1>Hello World</h1>
</code></pre>
<p>
Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save your file.
</p>
<p>
Water is represented as H<sub>2</sub>O.
</p>
<p>
Einstein's equation is E = mc<sup>2</sup>.
</p>
<blockquote>
Learning by building is one of the best ways to understand
web development.
</blockquote>
<p>
The course was updated on
<time datetime="2026-10-01">October 1, 2026</time>.
</p>
</article>| Element | Purpose |
|---|---|
<h1>–<h6> |
Headings |
<p> |
Paragraph |
<br> |
Line break |
<hr> |
Thematic break |
<strong> |
Strong importance |
<b> |
Attention without added importance |
<em> |
Emphasis |
<i> |
Alternate voice/technical distinction |
<u> |
Annotation |
<mark> |
Highlight |
<small> |
Side comments/small print |
<del> |
Deleted content |
<ins> |
Inserted content |
<sup> |
Superscript |
<sub> |
Subscript |
<blockquote> |
Long quotation |
<q> |
Inline quotation |
<cite> |
Title of cited work |
<abbr> |
Abbreviation |
<time> |
Date/time |
<code> |
Code |
<pre> |
Preserved formatting |
<kbd> |
User input |
<samp> |
Program output |
<var> |
Variable |
<address> |
Contact information |
<wbr> |
Optional word-break opportunity |
Create an article called:
"My Journey Into Web Development"
It should contain:
My Journey Into Web DevelopmentWhy I Started
What I Am Learning
My Future Goals<strong><em><mark><del><ins><blockquote><abbr><time><code><kbd><sup><sub>Try to decide where each element makes semantic sense, rather than adding them randomly.
You should now be able to explain:
<strong> and <b>?<em> and <i>?<mark>?<del> and <s>?<ins>?<blockquote> used for?<blockquote> and <q>?<cite>?<abbr>?<time>?<code> and <pre>?<kbd>, <samp>, and <var>?<br> be used?Don't memorize HTML as:
<h1> = big
<strong> = bold
<em> = italicInstead learn:
<h1> → heading
<strong> → strong importance
<em> → emphasis
<mark> → highlighted relevance
<time> → date/time
<code> → code
<kbd> → user inputMeaning first. Styling later.
We'll learn how websites connect to each other using <a>, including absolute URLs, relative URLs, internal navigation, external links, page anchors, email links, telephone links, downloads, target, rel, security, SEO, and real-world navigation structures.
Mark it as complete to track your mastery.