HTML Basics

Every website you love is just labeled boxes.

▶ the lesson · narrated sketch video · tap for sound

the intro

HTML gives every page its skeleton. Tags are labeled boxes for content — headings, paragraphs, links, images — and the browser knows what each one means. Learn twenty tags well and you can structure any page on the internet.

the sample

a whole page skeleton

<h1>My page</h1>
<p>Talks about <a href="/stuff">stuff</a>.</p>
<ul>
  <li>one thing</li>
  <li>another</li>
</ul>
<img src="cat.jpg" alt="a cat">

fun fact ✦

There are over 110 HTML elements — but you will use about 20 of them every single day.

the docs

the deep dive

the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid

HTML gets mocked as not-real-programming, which is exactly backwards: it is an API you publish. Screen readers consume it, Google ranks it, reader modes and AI assistants parse it. The generic div does none of that — the article tag does.

you are writing for machines, not just people

html tagheadnavmainfooter
a page is a labeled outline, not a pile of boxes

key terms

element

One unit of page: opening tag, content, closing tag. The browser turns each one into a node it can style and script.

<a href="/about">About</a>

attribute

Settings attached to a tag. Links need href, images need src, and alt describes the picture.

class="card" id="signup"

semantic

Tags whose name says what the content is: nav, article, header. Meaning is what machines are reading for.

header, article, nav, main

void element

Tags with no closing pair and no content — they are complete on their own.

img, input, br, meta

how it works

  1. 1
    Pick the meaning

    Ask what the content is: a heading, a list, an article, a form. The answer picks the tag.

  2. 2
    Wrap and nest

    Put content between tags and nest containers inside each other. The outline should read like a document.

  3. 3
    Add attributes

    href for destinations, src for sources, alt for descriptions, class and id for hooks your CSS and JS will grab later.

  4. 4
    Open it in the browser

    No build step, no framework. Save the file, open it, break it, fix it. HTML is the fastest feedback loop in frontend.

the code, explained

an article a machine can read

1<article class="post">
announces: self-contained content, like a blog post
2 <h2>Why HTML matters</h2>
the outline: one h1 per page, h2 beneath it
3 <p>Semantic tags add
4 <strong>meaning</strong>.</p>
5 <a href="/posts">All posts</a>
6</article>

side by side

semantic

  • screen readers can navigate it
  • search engines rank it higher
  • reader modes extract it cleanly
  • the markup explains itself
VS

div soup

  • reads as anonymous boxes
  • SEO has to guess
  • nothing to navigate by
  • future you squints at it
🪤 gotcha

Nest wrong and the browser silently rewrites your tree: a paragraph cannot legally contain a div, so the parser closes it early. View-source looks fine; the DOM in DevTools is different. When layout mystifies you, inspect the Elements tab, not the source.

quick answers

How many tags do I actually need?

About twenty: headings, p, a, img, ul and li, form and its inputs, plus the landmark tags. MDN covers the long tail.

div or section?

div when the grouping exists only for styling. section or article when the region means something on its own.

Is HTML a programming language?

No — no logic, no variables. It is descriptive markup. The pedants are right, but so is the counterpoint: nothing on the web works without it.

quick hits about HTML Basics

short answers · interviews, tips, trivia & hidden gems

🎤 interview

Why do interviewers love semantic HTML?watch ↗

📚 tutorial

How do you collect user input?watch ↗

🔧 useful

One attribute for accessibility AND SEO?watch ↗

💎 deep

A native accordion with zero JavaScript?watch ↗

💎 deep

Attach custom data to elements?watch ↗

🧠 trivia

What version of HTML are we on?watch ↗