HTML Interview Questions: Fundamentals
Thirty five questions on document structure, elements, text and links, in the form interviewers actually ask them. Questions only.
- SQL Interview
-
HTML Interview
- HTML Interview Questions: Fundamentals
- HTML Interview Questions: Forms, Tables and Media
- HTML Interview Questions: Semantics and Accessibility
- HTML Interview Questions: SEO, Performance and Tooling
- Scenario Based Interview Questions
- Rapid Fire and Fresher Round Questions
- Live Coding and Project Explanation Rounds
How to prepare with these
Questions only. No model answers, and that is the useful format for interview preparation.
An answer you memorised sounds memorised. An interviewer notices immediately, and the follow up question - why? - exposes it. What works is being able to explain a thing in your own words and give an example from something you built.
For each question below: write your answer, say it out loud, then check it against the notes in this path. If your explanation needs more than four sentences, you do not understand it well enough yet.
The opening questions
- What is HTML, and is it a programming language? Justify your answer.
- What is the difference between HTML and HTML5?
- Explain the difference between a tag, an element and an attribute.
- What does
<!DOCTYPE html>do? What happens without it? - What is quirks mode and why does it exist?
- Name the required parts of a minimal valid HTML document.
- What is the difference between the
headand thebody? - What happens if you put a visible element inside the
head? - Why does the
langattribute matter? - Is HTML case sensitive? Which parts, and which not?
Elements and attributes
- What is a void element? Name five.
- Why do void elements not have closing tags?
- Is
<br />valid HTML? What does the browser do with the slash? - What are global attributes? Name six.
- What is the difference between
idandclass? When would you use each? - Why must an
idbe unique? Name three things that break otherwise. - What is a boolean attribute? What does
disabled="false"do? - How do you add custom data to an element validly? How do you read it back?
- Why should attribute values always be quoted?
- What does the
titleattribute do, and why is it unreliable?
Block and inline
- Explain the difference between block level and inline elements.
- Give three examples of each.
- Which CSS properties do not apply to a plain inline element?
- Why can a
pnot contain adiv? What does the parser do if you write one? - What is
display: inline-blockand when is it useful? - Does changing
displaychange what an element means?
Text elements
- How many heading levels are there and how do you choose between them?
- Should a page have more than one
h1? Explain your position. - What is the difference between
strongandb? - What is the difference between
emandi? - What happens to whitespace in HTML, and how do you preserve it?
- What is the difference between
and a normal space? - Which characters must be escaped in HTML content, and why?
- What is the semantic meaning of
hr? - When would you use
markrather thanstrong?
Follow up questions you should expect
Interviewers rarely stop at the first answer. Be ready for these:
| If you say | Expect |
|---|---|
| Semantic HTML is important | Give me four specific things it enables. |
| The doctype declares the version | Which version does <!DOCTYPE html> declare? |
Use strong for important text | What does a screen reader do differently with it? |
| Ids must be unique | What actually breaks if two elements share one? |
| Block elements start on a new line | What containment rule follows from that? |
| HTML5 added semantic tags | What did HTML5 remove, and why? |
Answering well
- Give the rule, then an example. A void element has no content so it takes no closing tag -
img,br,input. - Say what breaks. Naming the failure shows you have hit it in practice.
- Refer to something you built. On the portfolio I built, I used... is worth more than any definition.
- Say when you do not know, then say how you would find out. That answer scores better than a confident wrong one.
- Keep it short. Answer, example, stop. Let them ask the follow up.
Practice
- Answer all thirty five out loud, timing yourself. Aim for under a minute each.
- Record yourself on five and listen back. Where did you waffle?
- For each answer, add a sentence naming something you built that used it.
- Have someone else ask them in a random order.