HTML — the complete reference

87 topics · 16 chapters · ~45 min read · updated 2026-08
reading progress
0%
How to use this guide. Read it start to finish once, then treat it as a revision shelf — come back in six months and skim a chapter. You don't memorize tags; you learn which category a problem belongs to and reach for the right element. The master checklist at the end is your "ready for CSS" test.
// 01

Foundations

What HTML is, what it isn't, and the skeleton every document shares.

01

What is HTML?

HTML stands for HyperText Markup Language. It is not a programming language — it has no logic, no loops, no conditions. It provides the structure and meaning of a webpage.

  • HTML → structure / meaning
  • CSS → presentation / style
  • JavaScript → behavior / logic

When the browser parses HTML it builds an in-memory tree of elements called the DOM (Document Object Model). JavaScript then manipulates that DOM.

02

Document structure

Every HTML page shares the same skeleton. Know what each part is for:

HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Website</title>
  </head>
  <body>
    <h1>Hello World</h1>
  </body>
</html>
  • <!DOCTYPE html> — tells the browser this is HTML5 and to render in standards mode.
  • <html lang="en"> — the root element; lang declares the document language (helps screen readers and search engines).
  • <head> — machine-readable metadata: title, meta, links, scripts.
  • <meta> — metadata about the document.
  • <title> — the tab name and the search-engine headline.
  • <body> — everything the user actually sees.
03

Elements, tags & attributes

The difference matters. An element is the whole thing; tags are its opening/closing markers; an attribute configures it.

HTML
<p class="text">Hello</p>
  • p → element / tag
  • class → attribute
  • "text" → attribute value

Common attributes: id, class, style, title, hidden, lang, dir, data-*, aria-*.

04

Block vs inline

Block elements start on a new line and occupy the full available width. Inline elements flow within surrounding text.

HTML
<!-- block -->
<div> <p> <h1> <section> <article> <header>
<footer> <nav> <main> <ul> <table> <form>

<!-- inline -->
<span> <a> <strong> <em> <img> <input>
<button> <code>

Understand this before you touch CSS layout — display behavior is built on it.

05

Comments

HTML
<!-- This is a comment. It is not rendered. -->
Never put passwords, API keys, or secrets in HTML comments — the source is public to anyone who opens the page.
06

HTML entities

Reserved characters and special symbols are written as entities so the parser doesn't misinterpret them:

HTML
&nbsp;  no-break space
&lt;    <
&gt;    >
&amp;   &
&quot;  "
&apos;  '
HTML
<p>5 &lt; 10</p>

Rendered as: 5 < 10

// 02

Text & Semantics

Choosing the right element for meaning — not for appearance. CSS owns appearance.

07

Headings h1–h6

HTML
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Do not pick a heading by size — pick by document structure. One <h1> per page, then nest in order. Style with CSS, not bigger heading numbers.
08

Paragraph, br, hr

HTML
<p>A paragraph of text.</p>
<p>Line one<br>line two</p>
<hr>
  • <p> — paragraph.
  • <br> — a single line break inside text.
  • <hr> — a thematic break (renders as a rule).
Never stack <br> tags for vertical spacing — that's a CSS margin/padding job.
09

strong, em, mark, del, ins

HTML
<strong>Important</strong>   semantic emphasis / importance
<em>Emphasized</em>           stress emphasis
<mark>Highlighted</mark>       marked / highlighted
<del>Old price</del>           deleted content
<ins>New price</ins>           inserted content
  • strong → strong importance (browsers render bold).
  • em → stress emphasis (rendered italic).
  • mark → highlighted, like a marker pen.
  • del / ins → corrections and edits; perfect for showing a strike-through "old → new" pattern.
10

sub, sup, small

HTML
H<sub>2</sub>O
x<sup>2</sup>
<small>Copyright information</small>

sub → subscript (chemistry), sup → superscript (exponents), small → side comments / legal fine print.

11

code & pre

HTML
<p>Run <code>npm start</code> to begin.</p>

<pre>
  Hello
      World
</pre>
  • code → inline code inside prose.
  • pre → preformatted text; whitespace and newlines are preserved verbatim. Put a code inside pre for a code block.
12

blockquote & q

HTML
<blockquote cite="https://example.com/source">
  This is a quotation.
</blockquote>

<p>He said, <q>Hello</q>.</p>

blockquote → a block-level quotation; q → a short inline quotation.

13

abbr, cite, time

HTML
<abbr title="HyperText Markup Language">HTML</abbr>

<cite>Clean Code</cite>

<time datetime="2026-08-13">August 13, 2026</time>
  • abbr → abbreviation, full form in title.
  • cite → the title of a creative work.
  • time → a machine-readable date/time in datetime — great for SEO and structured data.
// 03

Links & Navigation

The web is a web because of links. Get href right and everything else follows.

14

The anchor tag

HTML
<a href="https://example.com">Visit</a>

href is the destination. Without it the link does nothing.

15

Relative vs absolute URLs

HTML
<!-- absolute: full address -->
<a href="https://example.com/about">About</a>

<!-- relative: relative to the current page -->
<a href="about.html">About</a>

<!-- root-relative: relative to the site root -->
<a href="/images/logo.png">Logo</a>

Use relative URLs inside your own site so it keeps working when deployed.

16

Fragment links

A link to a section of a page, using an element's id:

HTML
<a href="#contact">Contact</a>

<section id="contact">
  ...
</section>
17

target & rel

HTML
<a href="https://example.com" target="_blank" rel="noopener noreferrer">
  Visit
</a>
  • target="_blank" → open in a new tab.
  • rel="noopener" → the new page can't access window.opener (security + performance).
  • rel="noreferrer" → hides the referrer.
Always pair target="_blank" with rel="noopener".
18

mailto / tel

HTML
<a href="mailto:test@example.com">Email</a>
<a href="tel:+880123456789">Call</a>

These launch the visitor's mail app / phone dialer instead of navigating.

// 04

Images & Media

Pictures, sound, video and embedded content — and the performance habits that come with them.

19

The img element

HTML
<img src="image.jpg" alt="A mountain">

src is the image source. alt is the alternative text — describe the image's meaning, not its appearance.

20

alt text

HTML
<!-- bad: no alt -->
<img src="cat.jpg">

<!-- good: describes the image -->
<img src="cat.jpg" alt="White cat sitting on a chair">

<!-- decorative: empty alt is intentional -->
<img src="decoration.png" alt="">

Missing alt hurts accessibility and SEO. For decorative images, an empty alt="" tells screen readers to skip it.

21

width, height, loading

HTML
<img src="image.jpg" alt="A mountain" width="800" height="500" loading="lazy">
  • width / height — reserve space so the layout doesn't jump while loading.
  • loading="lazy" — browser defers the download until the image is near the viewport.
22

Responsive images: srcset / sizes

Give the browser candidates with srcset and rules with sizes. It picks the best file for the viewport and device:

HTML
<img
  src="small.jpg"
  srcset="small.jpg 480w, medium.jpg 800w, large.jpg 1200w"
  sizes="(max-width: 600px) 480px, (max-width: 1000px) 800px, 1200px"
  alt="Mountain">

The w values are the image's intrinsic width in pixels; the browser compares them against sizes and its own knowledge of the device.

23

The picture element

For art direction — showing genuinely different crops per screen size:

HTML
<picture>
  <source media="(max-width: 600px)" srcset="mobile.jpg">
  <source media="(min-width: 601px)" srcset="desktop.jpg">
  <img src="desktop.jpg" alt="Landscape">
</picture>

The img inside is the fallback — it must always be present.

24

Audio

HTML
<audio controls>
  <source src="song.mp3" type="audio/mpeg">
</audio>

Useful attributes: controls, autoplay, loop, muted, preload. Browsers commonly block autoplay with sound.

25

Video

HTML
<video controls poster="thumbnail.jpg" width="800">
  <source src="video.mp4" type="video/mp4">
</video>

Know: controls, autoplay, muted, loop, poster, preload, width, height.

26

iframe & embedded content

iframe embeds another document. You'll meet it with YouTube, Google Maps, dashboards and external widgets.

HTML
<iframe src="https://example.com" title="Example website">
</iframe>

Always give iframes a title. embed and object exist for plugins/legacy content — you'll rarely need them.

27

SVG

HTML
<svg width="100" height="100" viewBox="0 0 100 100">
  <circle cx="50" cy="50" r="40" fill="tomato"/>
</svg>

SVG is vector and lives in the DOM — it scales crisply and can be styled and scripted like any element.

28

Canvas

HTML
<canvas id="myCanvas" width="300" height="150"></canvas>

Canvas is a bitmap drawing surface — it draws nothing until JavaScript does. SVG → vector/DOM; Canvas → pixel drawing.

// 05

Lists & Tables

Structured content. Backend data almost always ends up in tables.

29

Unordered & ordered lists

HTML
<ul>
  <li>HTML</li>
  <li>CSS</li>
  <li>JavaScript</li>
</ul>

<ol>
  <li>Install</li>
  <li>Configure</li>
  <li>Run</li>
</ol>

ul → unordered (bullets), ol → ordered (numbers), items wrapped in li. Nest ul/ol only inside li.

30

Description lists

HTML
<dl>
  <dt>HTML</dt>
  <dd>Markup language for webpages.</dd>

  <dt>CSS</dt>
  <dd>Styles webpages.</dd>
</dl>

dl → description list, dt → term, dd → description.

31

Tables

HTML
<table>
  <caption>Students</caption>
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Tanzir</td>
      <td>23</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>Total</td>
      <td>1</td>
    </tr>
  </tfoot>
</table>
  • caption → table title.
  • thead / tbody / tfoot → header, body, footer groups.
  • tr → row, th → header cell, td → data cell.

Use tables only for real tabular data — never for page layout.

32

colspan / rowspan

HTML
<td colspan="2">Total</td>  <!-- spans 2 columns -->
<td rowspan="3">Merged</td>  <!-- spans 3 rows -->
// 06

Forms

Master forms. They are the gateway between your frontend and any backend.

33

Form basics

HTML
<form action="/submit" method="POST">
  <label for="name">Name</label>
  <input type="text" id="name" name="name">

  <button type="submit">Submit</button>
</form>

action → where data goes. method → how it travels (GET/POST).

34

label & fieldset

HTML
<label for="email">Email</label>
<input id="email" type="email">

<fieldset>
  <legend>Shipping address</legend>
  ...
</fieldset>
  • label + matching for/id ties a caption to its field — clicking the label focuses the input, and screen readers announce it.
  • fieldset groups related fields, legend names the group.
35

Input types

The type attribute changes behavior, validation and the on-screen keyboard. Know these:

HTML
text, password, email, number, tel, url, search,
date, time, datetime-local, month, week,
color, file, checkbox, radio, range, hidden,
submit, reset, button
HTML
<input type="email">
<input type="password">
<input type="number" min="1" max="10">
<input type="date">
<input type="file">
<input type="checkbox">
<input type="radio">
<input type="color">

type="email" alone gives you format validation for free.

36

Form attributes

HTML
<input type="email" name="email" placeholder="Enter email"
  required autocomplete="email" maxlength="254">

<input type="number" min="18" max="100" step="1">
<input type="text" minlength="8" pattern="[A-Za-z]+">
<input disabled>
<input readonly value="fixed">
<input type="checkbox" checked>
<select><option selected>Chosen</option></select>
<input type="file" accept="image/png, image/jpeg">

Know: name, value, placeholder, required, disabled, readonly, checked, selected, min, max, step, minlength, maxlength, pattern, autocomplete, autofocus, multiple, accept.

37

Radio buttons

Same name = same group = only one selectable:

HTML
<label>
  <input type="radio" name="gender" value="male"> Male
</label>
<label>
  <input type="radio" name="gender" value="female"> Female
</label>
38

Checkboxes

HTML
<label>
  <input type="checkbox" name="skills" value="html"> HTML
</label>
<label>
  <input type="checkbox" name="skills" value="css"> CSS
</label>

Multiple boxes may be checked; they share a name but each keeps its own value.

39

Select / optgroup

HTML
<select name="country">
  <option value="bd">Bangladesh</option>
  <option value="in">India</option>
</select>

<select multiple>...</select>

<select>
  <optgroup label="Asia">
    <option>Bangladesh</option>
    <option>Japan</option>
  </optgroup>
</select>
40

Textarea

HTML
<textarea name="message" rows="5" cols="30"
  placeholder="Write something..."></textarea>

Multi-line text input — note it has content, not a value attribute.

41

File upload

HTML
<input type="file">
<input type="file" multiple>
<input type="file" accept="image/png, image/jpeg">

File uploads travel in multipart/form-data — set it on the form:

HTML
<form action="/upload" method="POST" enctype="multipart/form-data">
42

Built-in validation

HTML
<input required>
<input type="email" required>
<input minlength="8">
<input maxlength="20">
<input type="number" min="18" max="100">
<input pattern="[A-Za-z]+">
Client-side validation is not security. A user can bypass anything the browser enforces. Server validation is mandatory.
43

The name attribute

HTML
<input type="text" name="username">

name is the key the value is sent under. Without it, the field's value generally won't be submitted at all. A field with no name sends nothing.

44

GET vs POST

HTML
<form action="/search" method="GET">...</form>   <!-- search, filters, reading -->
<form action="/login" method="POST">...</form>  <!-- login, create, upload -->
  • GET → data in the URL query string (/search?q=html). Good for searches and filters.
  • POST → data in the request body. Good for login, registration, creating, uploading.
45

enctype

HTML
application/x-www-form-urlencoded  <!-- default -->
multipart/form-data                <!-- REQUIRED for file uploads -->
text/plain                         <!-- rarely used -->

Know when multipart/form-data is necessary: whenever a file is in the form.

46

Client vs server validation

HTML validation helps the user; backend validation protects your app.

CODE
Frontend validation
      ↓
Backend validation
      ↓
Database
Backend validation is mandatory. This connects HTML directly to Express, Node, REST APIs and authentication later.
// 07

Semantic HTML

Name the box by its meaning, not its appearance. Your markup is your documentation.

47

Why semantics matter

Semantic elements describe what content is. Using them improves:

  • Accessibility — assistive tech reads the meaning.
  • SEO — search engines understand the structure.
  • Maintainability — a page you can read like a document.
  • Readability — nav beats div class="navigation".
48

The layout elements

HTML
<header>  <!-- page or section intro: logo, headline, nav -->
<nav>      <!-- navigation links -->
<main>     <!-- the dominant content (one per page) -->
<section>  <!-- a themed group of content -->
<article>  <!-- self-contained: post, card, comment -->
<aside>    <!-- tangentially related: sidebar, ads, notes -->
<footer>  <!-- closing info: author, links, copyright -->

Also remember figure + figcaption for illustrations and address for contact info.

49

A complete semantic page

HTML
<body>
  <header>
    <nav>...</nav>
  </header>

  <main>
    <section>...</section>
    <article>...</article>
    <aside>...</aside>
  </main>

  <footer>...</footer>
</body>
50

div / span & div soup

HTML
<div>...</div>              <!-- block-level generic container -->
<p>Hello <span>world</span></p> <!-- inline generic container -->

div and span are last resorts when no semantic element fits. Avoid this:

HTML
<div>
  <div>
    <div>
      <div>...

That's div soup — use semantic elements instead.

51

id vs class

HTML
<div id="header">...</div>   <!-- unique in the document -->
<div class="card">...</div>    <!-- reusable -->

id — unique, one per document, used by links, JS and CSS targeting. class — reusable, heavily used with CSS and JavaScript. Duplicate IDs are invalid.

52

data-* attributes

Your own private attributes for JavaScript — the dataset API reads them:

HTML
<button data-user-id="123">Delete</button>

<div data-product-id="55" data-category="laptop"></div>
JS
button.dataset.userId;      // "123"
div.dataset.productId;      // "55"
div.dataset.category;       // "laptop"
53

Global attributes

Work on every element. You won't use them all daily — but know what each does:

HTML
id, class, style, title, lang, dir,
hidden, tabindex, contenteditable, draggable,
spellcheck, translate, data-*
// 08

Head, Meta & SEO

Invisible to users, critical to browsers, screen readers and search engines.

54

The head element

HTML
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Website</title>
  <link rel="stylesheet" href="style.css">
</head>

The head holds metadata, not visible content.

55

meta essentials

HTML
<title>My Website</title>          <!-- tab + search headline -->

<meta charset="UTF-8">              <!-- character encoding -->

<meta name="viewport"
      content="width=device-width, initial-scale=1.0">  <!-- responsive -->

<meta name="description"
      content="My website description">  <!-- SEO snippet -->

<meta name="robots" content="index, follow">  <!-- crawler rules -->

<link rel="canonical" href="https://example.com/page">  <!-- original URL -->

<link rel="icon" href="favicon.ico">  <!-- tab icon -->
56

External CSS & JS

HTML
<link rel="stylesheet" href="style.css">

<script src="script.js"></script>      <!-- blocks parsing -->
<script src="script.js" defer></script>  <!-- runs after HTML parsed -->
<script src="script.js" async></script>  <!-- loads & runs ASAP -->

Understand the defer / async difference before JavaScript — it changes when your code runs.

57

base & favicon

HTML
<base href="/">   <!-- base URL for all relative links (rare, know it) -->

<link rel="icon" href="/favicon.ico" type="image/x-icon">
58

SEO basics

HTML does a lot of SEO work for you:

  • One proper <title> and <meta name="description"> per page.
  • Semantic headings — exactly one <h1>.
  • Semantic HTML structure (header/main/footer).
  • Meaningful link text — not "click here".
  • Image alt text.
  • rel="canonical" for duplicate-safe URLs.
  • Structured data basics (JSON-LD) for rich results.
// 09

Accessibility

Not optional. The best accessibility is native HTML used correctly.

59

Why accessibility

Accessibility (a11y) means the page works for everyone — keyboard users, screen readers, low-vision users, and more. Semantic HTML is the foundation; ARIA fills the gaps.

60

Labels, alt & native controls

HTML
<!-- label your fields -->
<label for="email">Email</label>
<input id="email" type="email">

<!-- describe your images -->
<img src="profile.jpg" alt="John Doe">

<!-- use a real button, not a clickable div -->
<button type="submit">Submit</button>
<!-- <div onclick="submitForm()">Submit</div>  -- DON'T -->

Use native controls whenever possible — they're keyboard-accessible and announced correctly for free.

61

ARIA

ARIA = Accessible Rich Internet Applications. It adjusts the accessibility tree when native HTML isn't enough.

HTML
<button aria-label="Close menu">×</button>

aria-label        <!-- accessible name -->
aria-labelledby   <!-- name from another element -->
aria-describedby  <!-- extra description -->
aria-hidden       <!-- hide from AT -->
aria-expanded     <!-- open/closed state -->
aria-controls     <!-- what this controls -->
aria-current      <!-- current item (e.g. page) -->
aria-live         <!-- announce dynamic updates -->
role              <!-- override/define a role -->
Rule: semantic HTML first. ARIA only where native HTML falls short. Don't sprinkle ARIA everywhere.
62

Keyboard accessibility

HTML
<button>Submit</button>  <!-- natively focusable + Enter/Space works -->

<div tabindex="0">...</div>  <!-- made focusable manually (sparingly) -->

Everything interactive should be reachable and operable by keyboard. tabindex exists, but prefer native elements.

63

The accessibility tree

Browsers derive a separate accessibility tree from the DOM for assistive technology. Semantic elements map to meaningful roles automatically — that's why:

HTML
<button>Submit</button>  <!-- becomes role="button", keyboard-able -->
<div>Submit</div>          <!-- no role, no behavior -->
// 10

Modern Elements

Today's HTML ships with interactive primitives that used to require JavaScript.

64

details / summary

Native accordion — no JavaScript required:

HTML
<details>
  <summary>What is HTML?</summary>
  <p>HTML structures webpages.</p>
</details>

Add open to start expanded.

65

dialog

HTML
<dialog id="modal">
  <p>Confirmation</p>
  <button>Close</button>
</dialog>

Modals, confirmations and dialogs. JavaScript calls showModal() / close() on it.

66

template

An inert HTML fragment cloned later by JavaScript:

HTML
<template id="cardTemplate">
  <div class="card">
    <h2></h2>
  </div>
</template>

The browser renders nothing until the template's content is cloned into the DOM.

67

Web Components concept

HTML
<my-card></my-card>

Custom elements, Shadow DOM and templates together form Web Components. You don't need to master them before React — just understand the idea of reusable, encapsulated custom tags.

68

contenteditable

HTML
<div contenteditable="true">
  Edit this text.
</div>

Makes content editable in the browser — the basis of rich text editors and CMS document editing.

69

hidden

HTML
<div hidden>Hidden content</div>

Removes the element from rendering entirely. Different from merely hiding visually with CSS (visibility keeps the space, hidden doesn't).

70

noscript

HTML
<noscript>
  Please enable JavaScript.
</noscript>

Displayed only when JavaScript is unavailable.

// 11

Performance & Security

HTML that loads fast and doesn't leak trust.

71

defer / async

HTML
<script src="script.js"></script>      <!-- blocks HTML parsing -->
<script src="script.js" defer></script>  <!-- waits for HTML, runs in order -->
<script src="script.js" async></script>  <!-- downloads async, runs when ready -->

defer is usually the right default for scripts that touch the page.

72

loading="lazy"

HTML
<img src="large-image.jpg" loading="lazy" alt="...">
<iframe src="map.html" loading="lazy" title="Map"></iframe>

Defer off-screen media. One of the cheapest performance wins in HTML.

73

Resource hints

HTML
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preload" href="font.woff2" as="font" type="font/woff2" crossorigin>
<link rel="prefetch" href="next-page.html">
<link rel="dns-prefetch" href="https://api.example.com">
  • preconnect → start the connection early.
  • preload → fetch a critical resource now.
  • prefetch → fetch for a future navigation.
  • dns-prefetch → resolve the domain early.

Use them only when there's a real performance reason.

74

iframe security

HTML
<iframe
  src="https://untrusted.example"
  sandbox="allow-scripts"
  loading="lazy"
  referrerpolicy="no-referrer"
  title="Embedded content">
</iframe>

sandbox restricts what the embedded document can do; allow and referrerpolicy tighten it further. Embedding third-party content has real security implications.

75

Security checklist

  • rel="noopener" on every target="_blank" link.
  • sandbox + referrerpolicy on untrusted iframes.
  • autocomplete="off" where sensitive (sparingly).
  • Never put secrets in HTML, comments or frontend code.
  • Validate and sanitize everything again on the backend.
HTML cannot secure an app by itself. Security must also live in the backend, auth, HTTP headers, cookies and the database.
// 12

URLs & Paths

Critical the moment you deploy a real site.

76

Absolute / relative / root-relative

URL
https://example.com/images/logo.png   <!-- absolute -->
images/logo.png                        <!-- relative -->
/images/logo.png                       <!-- root-relative -->
#contact                               <!-- fragment -->

Absolute → full address. Relative → from the current file. Root-relative → from the site root (needs a real server/domain). Fragment → a section of the page.

77

Path practice

Common project layout and how files reference each other:

FILES
project/
  index.html
  about.html
  css/style.css
  js/script.js
  images/logo.png

about.html links to:
  css/style.css        <!-- same-level sibling folder -->
  images/logo.png
  index.html
// 13

The DOM

The bridge between your markup and JavaScript.

78

The DOM tree

The browser turns your markup into a tree of objects:

DOM
Document
  ↓ html
      ↓ head
      ↓ body
          ↓ h1
              ↓ "Hello"

JavaScript interacts with this tree:

JS
document.querySelector('h1')
document.getElementById('header')
element.textContent
element.innerHTML
element.classList
79

HTML vs DOM

Don't confuse them. HTML is your source markup. DOM is the browser's live, in-memory representation that JavaScript reads and modifies. You can change the DOM without touching the source HTML at all.

// 14

Mistakes & Deprecated

What gives beginner markup away — and what to use instead.

80

Common mistakes

FIX
<!-- 1. <br> stacks for spacing  -- use CSS margin/padding -->
<br><br><br>

<!-- 2. headings chosen by size  -- choose by structure -->
<h1>Small text</h1>

<!-- 3. div for everything  -- use semantic elements -->
<div class="nav">...</div>

<!-- 4. missing alt -->
<img src="cat.jpg">

<!-- 5. unlabelled inputs -->
<input type="email">

<!-- 6. clickable divs -->
<div onclick="...">...</div>

<!-- 7. duplicate ids -->
<div id="card"></div>
<div id="card"></div>
Secrets in HTML. Never ship passwords, API keys, private keys or database credentials in markup — the source is public.
81

Deprecated tags

Recognize these old tags, but never use them in new projects — CSS replaces them all:

HTML
<center> <font> <marquee> <big> <strike> <u>
82

Internationalization

HTML
<html lang="en">        <!-- English -->
<html lang="bn">        <!-- Bangla -->

<span lang="bn">বংাংা</span>   <!-- mixed-content span -->

dir="ltr"                  <!-- left-to-right -->
dir="rtl"                  <!-- right-to-left (Arabic, etc.) -->
// 15

Tools & Validation

How to check your work, and how to organize it.

83

HTML validation

Run your pages through an HTML validator to catch:

  • Invalid nesting
  • Missing required attributes
  • Duplicate IDs
  • Invalid markup
  • Accessibility issues

Tools: the W3C Nu Validator, or browser extension validators. Worth it on serious projects.

84

Browser DevTools

HTML learning isn't complete without DevTools (Chrome/Edge → F12 or Ctrl+Shift+I). You should be able to:

  • Inspect and edit HTML live
  • Inspect attributes and the DOM
  • Find and tweak CSS
  • Check accessibility
  • Watch network requests
  • View page source
  • Test responsive layouts
85

Project file structure

FILES
project/
  ↓ index.html
  ↓ about.html
  ↓ css/
  ↓     style.css
  ↓ js/
  ↓     script.js
  ↓ images/
  ↓     logo.png
  ↓ assets/

Frameworks will change the structure later, but the underlying ideas (separate concerns, one page = one file) stay.

// 16

Mental Model

Step back and see how the pieces fit.

86

HTML + CSS + JS

MODEL
            WEBSITE
               ↓
    HTML     CSS       JS
   Structure Style  Behavior
               ↓
             Browser
               ↓
              DOM
HTML
<button id="btn">Click me</button>

HTML creates the button. CSS styles it. JavaScript makes it do something.

87

What not to memorize

You do not need to memorize every tag. Think in terms of intent:

  • "I need a navigation menu" → <nav>
  • "I need an email field" → <input type="email">
  • "I need a button" → <button>
  • "I need an article" → <article>

Understand what element to choose and why — that's the skill.

// 17

Master checklist

If you can work through this without looking up basic syntax, you're ready for CSS. Work it into your muscle memory over a week, then revise monthly.

Foundation

HTML document structure
Tags / elements
Attributes
Nesting
Block vs inline
Comments
Entities

Text

h1–h6 in structure order
p, strong, em, mark
del / ins, sub / sup
code / pre
blockquote / q
abbr / cite / time

Navigation

a + href
Relative / absolute URLs
Fragments (#id)
target + rel="noopener"
mailto / tel

Images & Media

img + src + alt
width / height
loading="lazy"
srcset / sizes
picture
audio / video basics

Lists & Tables

ul / ol / li
dl / dt / dd
table + caption
thead / tbody / tfoot
colspan / rowspan

Forms

form + action + method
label + for/id
input types
textarea / select / optgroup
name / value / required
GET vs POST
enctype + file uploads
pattern / min / max / step

Semantic HTML

header / nav / main
section / article / aside / footer
figure / figcaption
address / time
div soup avoided

Accessibility

labels on all inputs
alt on all images
native buttons, not divs
keyboard reachable
ARIA only when needed

Head & Meta

title
charset / viewport
description / robots
favicon / canonical
defer / async scripts
preconnect / preload basics

Modern & DOM

data-* attributes
details / summary
dialog / template
contenteditable / hidden
noscript
Web Components concept
DOM model + DevTools
SEO + performance basics
You're ready for CSS when you can build a multi-page site — navbar, forms, tables, images, semantic structure, accessible markup — without stopping to look up basic syntax.