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
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, mainvoid element
Tags with no closing pair and no content — they are complete on their own.
img, input, br, metahow it works
- 1Pick the meaning
Ask what the content is: a heading, a list, an article, a form. The answer picks the tag.
- 2Wrap and nest
Put content between tags and nest containers inside each other. The outline should read like a document.
- 3Add attributes
href for destinations, src for sources, alt for descriptions, class and id for hooks your CSS and JS will grab later.
- 4Open 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
side by side
semantic
- screen readers can navigate it
- search engines rank it higher
- reader modes extract it cleanly
- the markup explains itself
div soup
- reads as anonymous boxes
- SEO has to guess
- nothing to navigate by
- future you squints at it
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
Why do interviewers love semantic HTML?watch ↗
How do you collect user input?watch ↗
One attribute for accessibility AND SEO?watch ↗
A native accordion with zero JavaScript?watch ↗
Attach custom data to elements?watch ↗
What version of HTML are we on?watch ↗