HTML Quiz
Test what you've learned across the whole HTML series. Try each question before opening the answer. If you get one wrong, follow the link to revise that page.
Getting started
1. What does HTML stand for, and what kind of language is it?
- A. HighText Machine Language, a programming language
- B. HyperText Markup Language, a markup language
- C. HyperText Markup Language, a programming language
- D. Home Tool Markup Language, a styling language
Show answer
B. HTML describes the structure and meaning of content; it has no variables or logic, so it isn't a programming language. See HTML Introduction.
2. When you visit www.example.com, what is the job of DNS?
- A. It stores the website's HTML files
- B. It turns the domain name into the server's IP address
- C. It draws the page on the screen
- D. It encrypts the connection
Show answer
B. DNS works like a contact list, looking up the IP address for a name before the browser can request the page. See How Websites Work.
3. What happens if you leave out <!DOCTYPE html>?
Show answer
The browser renders the page in quirks mode, imitating old browser bugs, so some CSS behaves differently. The doctype switches on standards mode. See Document Structure.
4. What is wrong with this code? <p>Fares rise at <em>rush hour</p></em>
Show answer
The tags overlap. <em> was opened last, so it must be closed first: </em></p>. See Elements & Attributes.
5. Is the button in <button disabled="false">Pay</button> enabled or disabled?
Show answer
Disabled. For boolean attributes, presence means true whatever the value. Remove the attribute to enable the button.
Text and content
6. Your page has an <h2> called "Fees". You want a sub-heading under it. Which element should you use?
- A.
<h1> - B.
<h3> - C.
<h4>, because it's smaller - D.
<strong>
Show answer
B. Headings go one level deeper at a time and are chosen for structure, not size. See Headings & Paragraphs.
7. What is the difference in meaning between <strong> and <b>?
Show answer
<strong> marks strong importance or urgency; <b> draws attention to text without giving it extra importance. Both are bold by default. See Text Formatting.
8. You are editing projects/weather.html. What href links to index.html in the folder above?
- A.
index.html - B.
/projects/index.html - C.
../index.html - D.
www.index.html
Show answer
C. .. means "go up one folder". See Links.
9. What alt text should a purely decorative swirl image have?
Show answer
An empty value, alt="", so screen readers skip it. Leaving alt out completely may make some screen readers read the file name. See Images.
10. How do you display the text <p> on a page without the browser treating it as a tag?
Show answer
Write it with entities: <p>. See Comments, Entities & Symbols.
Structure and layout
11. Why is <p>Intro <div>Box</div></p> a problem?
Show answer
A paragraph can only contain phrasing (inline-level) content. When the browser meets <div> it closes the paragraph automatically, so the div ends up outside it and the final </p> creates an extra empty paragraph. See Block & Inline Elements.
12. How many elements on one page can share the same id? And the same class?
Show answer
An id must be unique, so only one element. A class can be shared by any number of elements, and an element can have several classes. See Divs, Spans, Classes & IDs.
13. Which element best wraps a blog post that could be shared and read on its own?
- A.
<section> - B.
<div> - C.
<article> - D.
<aside>
Show answer
C. An <article> is self-contained content that makes sense on its own. See Semantic HTML.
Forms, media and the head
14. A form has <input type="text" id="phone">, but the phone number never reaches the server. What is the most likely cause?
Show answer
The input has no name attribute. Only controls with a name are submitted, as name=value pairs. Add name="phone". See HTML Forms.
15. True or false: adding required and pattern to your inputs means your server can trust the data it receives.
Show answer
False. Browser validation helps honest users, but anyone can remove the attributes or send requests without your form. Always validate again on the server. See Form Validation.
How did you do?
- 13–15 correct: excellent. Build the portfolio project if you haven't yet, then start the CSS series.
- 9–12 correct: good work. Revisit the pages linked from the questions you missed.
- 8 or fewer: no problem. Go back through the series with the Try-it editors open, and experiment until each idea clicks.
Key points
- HTML structures content; browsers fetch it from servers, build a tree and render it.
- Correct nesting, meaningful elements and good attributes (alt, lang, name, for/id) are the core skills.
- Semantic, accessible HTML helps every user, search engines and future you.
- Never trust client-side validation alone; next, learn CSS to style your pages.
Tip: use the ← and → keys to move between pages.
