⚡0 XP🔥0

Text, Links and Images

Lesson 2 of 6 ⏱ 4 min read ❓ 5-question quiz ▶ Runs HTML

Headings, paragraphs, bold and italic text, links to other pages and sections, images with alt text, and semantic page sections like header, nav, main and footer.

Headings and paragraphs#

HTML has six heading levels, <h1> (most important) to <h6>. Paragraphs use <p>.

▶ Try it YourselfHTML
Ctrl + Enter to run
Common Mistake

Don't choose a heading because of its size. <h1>-<h6> describe the outline of your page. Use CSS to change the size.

Formatting text#

Tag Meaning Looks like
<strong> important bold
<em> emphasis (stress) italic
<mark> highlighted highlighted
<small> fine print smaller text
<sub>, <sup> subscript, superscript H2O, x2
<code> computer code monospace
<blockquote> a long quotation indented block
▶ Try it YourselfHTML
Ctrl + Enter to run

Special characters (entities)#

Some characters have special meaning in HTML, so you write them as entities:

Write To show
&lt; &gt; < >
&amp; &
&nbsp; a space that never breaks to a new line
&copy; ©
&#8377; ₹

The anchor element <a> creates links. The href attribute says where to go.

▶ Try it YourselfHTML
Ctrl + Enter to run
Kind of link Example href
another website (absolute URL) https://www.python.org
a page on your site (relative URL) about.html, courses/python.html, ../index.html
a section of the same page #fees (matches id="fees")
email / phone mailto:name@site.com, tel:+91...
हिंदी में समझें

Absolute URL पूरा पता होता है (https://...) - जैसे किसी दूसरे शहर का पूरा address। Relative URL आपकी अपनी website के अंदर का रास्ता है (about.html) - जैसे कहना "बगल वाले कमरे में जाओ"।

Images#

<img> is a void element. src is the image file, alt describes it.

▶ Try it YourselfHTML
Ctrl + Enter to run
Tip

Always give width and height (or set them in CSS). The browser can then reserve space before the image loads, so the page doesn't "jump". For photos use .jpg or .webp, for logos and icons use .svg or .png.

Image with a caption#

<figure>
  <img src="rajwada.jpg" alt="Rajwada palace in Indore at sunset" width="400">
  <figcaption>Rajwada, Indore</figcaption>
</figure>

Semantic page sections#

Instead of using <div> for everything, HTML5 has semantic elements that describe each part of the page:

▶ Try it YourselfHTML
Ctrl + Enter to run
Element Use it for
<header> logo, site title, top area
<nav> the main menu links
<main> the main content (only one per page)
<section> a themed group of content with a heading
<article> a self-contained item - blog post, news item, product card
<aside> side content - related links, ads
<footer> copyright, contact, links at the bottom
<div>, <span> generic boxes with no meaning - use when nothing else fits

Semantic HTML helps screen readers, Google and other developers understand your page.

Summary#

  • Use <h1>-<h6> for the outline and <p> for paragraphs.
  • <strong>/<em> add meaning; entities like &lt; show special characters.
  • <a href> links to sites, pages, sections (#id), email and phone.
  • <img> needs src and a good alt description.
  • Prefer semantic elements (header, nav, main, footer...) over plain divs.

Quick Quiz

Q1.

How many <h1> headings should a normal page have?

Q2.

Which attribute opens a link in a new browser tab?

Q3.

Why is the alt attribute on <img> important?

Q4.

Which tag gives text strong importance (usually shown in bold)?

Q5.

What does <a href="#contact">Contact</a> do?