HTML Interview
15 essential Q&A
HTML Structure Interview: 15 Essential Q&A
Interview-focused questions on how an HTML document is structured and organized.
doctypeheadbodymetadatascripts
Quick Navigation
1What is the standard HTML document skeleton?easy
Answer: It starts with doctype, then
<html>, and inside it <head> and <body>.2What goes inside the
<head> section?easyAnswer: Metadata and resources like title, meta tags, stylesheets, favicon, and scripts (if needed).
3What goes inside the
<body>?easyAnswer: All visible page content: text, images, links, lists, forms, tables, and interactive UI.
4Why are meta tags important in structure?medium
Answer: Meta tags provide machine-readable information such as description, robots rules, and responsive behavior.
5What does
<meta charset="UTF-8"> do?easyAnswer: It defines character encoding so text (including symbols/languages) renders correctly.
6Why include viewport meta in modern pages?easy
Answer: It ensures responsive scaling and proper layout behavior on mobile devices.
7How does the
<title> tag help?easyAnswer: It defines browser tab text and strongly influences search snippet titles and share previews.
8Where should JavaScript be placed in structure?medium
Answer: Usually near the end of body or in head with
defer, to avoid blocking rendering.<script src="app.js" defer></script>9Where should CSS links be placed?easy
Answer: In the head section using
<link rel="stylesheet">, so styles are ready when content renders.10What is the purpose of HTML comments?easy
Answer: Comments document structure and intent for developers, but are ignored by browsers.
11Why is proper tag nesting important?medium
Answer: Correct nesting ensures predictable DOM structure, easier styling, better accessibility, and fewer bugs.
12What is semantic page structure?medium
Answer: Using meaningful landmarks like
header, nav, main, section, article, and footer.13How do
header, main, and footer improve layout structure?mediumAnswer: They clarify document regions for users, developers, and assistive tools, improving maintainability and navigation.
14Why validate HTML structure?medium
Answer: Validation catches structural mistakes early and improves compatibility across browsers/devices.
15Top structure best practices?medium
Answer: Keep hierarchy clean, use semantic landmarks, avoid deep unnecessary wrappers, and keep head metadata complete.
HTML Structure Cheat Sheet
Must Have
- Doctype + html lang
- Head metadata
- Clear body hierarchy
Semantic Regions
- header/nav/main
- section/article
- footer
Interview Angle
- Explain why, not just what
- Mention accessibility
- Mention SEO impact
Tricky Q&A (10 Questions)
16Which must be direct child concept of html element?tricky
Answer: Correct answer: head and body. html contains head and body.
17Metadata like title belongs in:tricky
Answer: Correct answer: head. head holds meta, title, link tags.
18Script defer attribute:tricky
Answer: Correct answer: Downloads parallel, executes after HTML parsed. defer delays execution until document parsed.
19Script async attribute:tricky
Answer: Correct answer: Executes when downloaded, may block. async scripts run ASAP when ready.
20link rel='stylesheet' goes in:tricky
Answer: Correct answer: head typically. Stylesheets are linked from head.
21Invalid nesting example:tricky
Answer: Correct answer: p inside p. Paragraphs cannot nest inside paragraphs.
22lang attribute on html helps:tricky
Answer: Correct answer: Screen readers and SEO language detection. lang declares document language.
23body element contains:tricky
Answer: Correct answer: Visible content. All visible page content lives in body.
24Favicon link uses:tricky
Answer: Correct answer: rel='icon'. link rel='icon' sets favicon.
25Proper closing tag rule:tricky
Answer: Correct answer: Close inner elements before outer. Nested tags must close LIFO order.