Headings and paragraphs#
HTML has six heading levels, <h1> (most important) to <h6>. Paragraphs use <p>.
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 |
Special characters (entities)#
Some characters have special meaning in HTML, so you write them as entities:
| Write | To show |
|---|---|
< > |
< > |
& |
& |
|
a space that never breaks to a new line |
© |
© |
₹ |
₹ |
Links#
The anchor element <a> creates links. The href attribute says where to go.
| 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.
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:
| 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<show special characters.<a href>links to sites, pages, sections (#id), email and phone.<img>needssrcand a goodaltdescription.- Prefer semantic elements (
header,nav,main,footer...) over plaindivs.