Common HTML elements
You'll learn the HTML elements you will see on almost every page, and why the right one matters.
Watch & read
Start with the required ones. The others are there when you need them.
Explanation
You know HTML is boxes inside boxes. Now you need to know which box to pick. There are about a dozen you will use every day.
Think of a class notice board. A big title at the top. Short notices under it. A list of exam dates. A phone number to call. Each piece has a job. HTML elements are the same: each element says what its content is, not how it looks.
The everyday ones:
<h1>to<h6>: headings, biggest to smallest. One<h1>per page.<p>: a paragraph of text.<a href="...">: a link to another page.<img src="..." alt="...">: an image.altdescribes it in words.<ul>with<li>items: a list. Use<ol>when order matters, like steps.<button>: something you press.<form>,<label>and<input>: a place to type, like a sign-up box.
<h2>Exam dates</h2><ul><li>Math: 12 May</li><li>Physics: 15 May</li></ul><img src="campus.jpg" alt="Students outside the library">
Elements that say what something means are called semantic elements. <nav> for the menu,
<main> for the main content, <footer> for the bottom. A blind user's screen reader reads these out,
so the user can jump straight to the menu. Google reads them too.
People often build everything from <div>, a box with no meaning. A <div> that looks like a button
cannot be reached with the Tab key, and a screen reader does not call it a button. Use <button>.
Another common one: an image with no alt. If the image fails to load, or the user cannot see, there is
nothing left.
When you read HTML, ask of each element: what is this content? Then check the tag says the same thing.
Code tour
Click a line number with a ring to read the note for that line.
Quick check
3 questions. Each one explains itself after you answer.
- 1 / 3What is the
alttext on an image for? - 2 / 3
- 3 / 3You want the steps of a recipe, in order. Which list?
Explain it back
How confident are you with Common HTML elements?
Done
alt or a div that should be a button.