HTML Interview Questions: Fundamentals

Thirty five questions on document structure, elements, text and links, in the form interviewers actually ask them. Questions only.

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

  1. What is HTML, and is it a programming language? Justify your answer.
  2. What is the difference between HTML and HTML5?
  3. Explain the difference between a tag, an element and an attribute.
  4. What does <!DOCTYPE html> do? What happens without it?
  5. What is quirks mode and why does it exist?
  6. Name the required parts of a minimal valid HTML document.
  7. What is the difference between the head and the body?
  8. What happens if you put a visible element inside the head?
  9. Why does the lang attribute matter?
  10. Is HTML case sensitive? Which parts, and which not?

Elements and attributes

  1. What is a void element? Name five.
  2. Why do void elements not have closing tags?
  3. Is <br /> valid HTML? What does the browser do with the slash?
  4. What are global attributes? Name six.
  5. What is the difference between id and class? When would you use each?
  6. Why must an id be unique? Name three things that break otherwise.
  7. What is a boolean attribute? What does disabled="false" do?
  8. How do you add custom data to an element validly? How do you read it back?
  9. Why should attribute values always be quoted?
  10. What does the title attribute do, and why is it unreliable?

Block and inline

  1. Explain the difference between block level and inline elements.
  2. Give three examples of each.
  3. Which CSS properties do not apply to a plain inline element?
  4. Why can a p not contain a div? What does the parser do if you write one?
  5. What is display: inline-block and when is it useful?
  6. Does changing display change what an element means?

Text elements

  1. How many heading levels are there and how do you choose between them?
  2. Should a page have more than one h1? Explain your position.
  3. What is the difference between strong and b?
  4. What is the difference between em and i?
  5. What happens to whitespace in HTML, and how do you preserve it?
  6. What is the difference between &nbsp; and a normal space?
  7. Which characters must be escaped in HTML content, and why?
  8. What is the semantic meaning of hr?
  9. When would you use mark rather than strong?

Follow up questions you should expect

Interviewers rarely stop at the first answer. Be ready for these:

If you sayExpect
Semantic HTML is importantGive me four specific things it enables.
The doctype declares the versionWhich version does <!DOCTYPE html> declare?
Use strong for important textWhat does a screen reader do differently with it?
Ids must be uniqueWhat actually breaks if two elements share one?
Block elements start on a new lineWhat containment rule follows from that?
HTML5 added semantic tagsWhat 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

  1. Answer all thirty five out loud, timing yourself. Aim for under a minute each.
  2. Record yourself on five and listen back. Where did you waffle?
  3. For each answer, add a sentence naming something you built that used it.
  4. Have someone else ask them in a random order.

Useful resources

Hand picked references for this topic
Written by Lorens Mishra

Default administrator account created by the installer.

Discussion

0 comments
Sign in to join the discussion.

No comments yet. Be the first to say something.