Practice Questions — HTML Document Structure and Boilerplate
← Back to NotesTopic-Specific Questions
Question 1
Easy
What is the purpose of
<!DOCTYPE html>?It tells the browser something about the HTML version.
It tells the browser to render the page using the HTML5 standard, not an older version or quirks mode.
Question 2
Easy
What is missing from this HTML?
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello</h1>
</body>
</html>Something should be on the very first line.
<!DOCTYPE html>
<html>
...Question 3
Easy
What does the
lang="en" attribute do on the <html> tag?It sets something about the content.
It tells the browser and screen readers that the page content is in English.
Question 4
Easy
What is missing from this page?
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Welcome</h1>
</body>
</html>The browser tab will show something weird without this.
The
<title> tag is missing from the head. Add <title>Your Title</title> inside the head section.Question 5
Easy
Where does the text inside the
<title> tag appear?Not on the page itself — look higher.
On the browser tab at the top of the window, in bookmarks, and in search engine results.
Question 6
Easy
Write the complete HTML5 boilerplate with the title 'My Practice Page' and the heading 'Hi there' in the body.
Include DOCTYPE, html (with lang), head (with meta charset, meta viewport, title), and body.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Practice Page</title>
</head>
<body>
<h1>Hi there</h1>
</body>
</html>Question 7
Easy
What does the viewport meta tag do?
It matters most on a specific kind of device.
It makes the page display properly on mobile phones by matching the screen width and not zooming out.
Question 8
Easy
Why is this comment not working (it shows up as text on the page)?
<!- This is a note ->Comments need a specific number of dashes.
<!-- This is a note -->Question 9
Easy
Which tag should contain the visible content of the page?
Not head — the other one.
<body>Question 10
Easy
Add an HTML comment above a heading that says 'This is the main title'.
Use
<!-- This is the main title -->
<h1>Welcome</h1>Question 11
Easy
What character encoding should you use in the meta charset tag?
The universal one.
UTF-8
Question 12
Medium
What is wrong with this nesting?
<p><strong>Important text</p></strong>The tags must close in the reverse order they were opened.
<p><strong>Important text</strong></p>Question 13
Medium
Write the HTML boilerplate for a Hindi language page titled 'Namaste Duniya'.
Use lang="hi" for Hindi.
<!DOCTYPE html>
<html lang="hi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Namaste Duniya</title>
</head>
<body>
<h1>Namaste Duniya</h1>
</body>
</html>Question 14
Medium
Which of these should go inside the head and which inside the body:
<title>, <h1>, <meta>, <p>?Metadata vs visible content.
Inside head:
<title> and <meta>. Inside body: <h1> and <p>.Question 15
Medium
Rohan wrote this boilerplate but something is wrong. Fix it:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF8">
<title>Test</title>
</head>
<body></body>
</html>Check the charset value carefully.
<meta charset="UTF-8">Question 16
Medium
Write a complete HTML page with a description meta tag that says 'A personal blog about cricket and coding by Vikram'.
Use
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A personal blog about cricket and coding by Vikram">
<title>Vikram's Blog</title>
</head>
<body>
<h1>Welcome to my blog</h1>
</body>
</html>Question 17
Medium
Will this HTML display the word 'hidden'?
<p>Visible</p>
<!-- <p>hidden</p> -->Anything between is ignored.
No. Only 'Visible' will be shown. The second paragraph is inside an HTML comment.
Question 18
Medium
This page does not look right on phones. What is the fix?
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello</h1>
</body>
</html>A meta tag is missing.
Add the viewport meta tag:
<meta name="viewport" content="width=device-width, initial-scale=1.0">Question 19
Medium
What is the difference between and
?
One is on the tab, the other is on the page.
<title> shows on the browser tab (inside head). <h1> is a visible heading on the page itself (inside body). They serve different purposes.Question 20
Medium
Write a complete HTML page that has two sections, each marked with an HTML comment explaining what it contains.
Use comments above each section.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Two Sections</title>
</head>
<body>
<!-- Introduction section -->
<h1>About Me</h1>
<p>I am learning HTML.</p>
<!-- Hobbies section -->
<h2>My Hobbies</h2>
<p>I enjoy reading and cricket.</p>
</body>
</html>Question 21
Hard
Why does this page show the h1 but not the second paragraph?
<body>
<h1>Hello</h1>
<!-- <p>First</p>
<p>Second</p> -->
</body>Look at the comment boundaries.
Both paragraphs are inside a multi-line comment. Remove the comment markers to show them, or move the closing
--> to hide only the first paragraph.Question 22
Hard
Write a complete HTML page with: proper boilerplate, author meta tag crediting 'Ananya Patel', description meta tag, title 'Ananya's Portfolio', and a body with an h1 and a short paragraph.
Combine all the meta tags you have learned so far.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Portfolio of Ananya Patel featuring art, writing, and coding projects.">
<meta name="author" content="Ananya Patel">
<title>Ananya's Portfolio</title>
</head>
<body>
<h1>Welcome to my portfolio</h1>
<p>Here you will find my art, stories, and small code projects.</p>
</body>
</html>Question 23
Hard
What is the difference between these two pieces of code visually?
<ul><li>A</li><li>B</li></ul>vs<ul>
<li>A</li>
<li>B</li>
</ul>Think about how the browser renders whitespace in HTML source.
There is no visual difference. Both render as a bulleted list with two items. HTML ignores extra whitespace in the source code.
Question 24
Hard
This boilerplate has three problems. Find them all:
<DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf8>
<title>Test
</head>
<body>
</body>
</html>Missing exclamation, missing quotes, unclosed title.
1.
<DOCTYPE html> should be <!DOCTYPE html> (missing !). 2. lang=en should be lang="en" (missing quotes). 3. <title>Test is missing its closing tag. Charset value should also be "UTF-8" with quotes and hyphen.Question 25
Hard
Write a fully valid HTML boilerplate with a comment section header above every major block in the body. Include intro, hobbies, and contact sections.
Structure with clear comments above each h2 section.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About Priya</title>
</head>
<body>
<!-- ===== Intro ===== -->
<h1>Priya Sharma</h1>
<p>Hi, I am a student and hobbyist coder.</p>
<!-- ===== Hobbies ===== -->
<h2>Hobbies</h2>
<p>Reading, painting, and HTML.</p>
<!-- ===== Contact ===== -->
<h2>Contact</h2>
<p>Email: priya@example.com</p>
</body>
</html>Mixed & Application Questions
Question 1
Easy
Which tag wraps ALL other HTML tags?
The grandparent of every element.
<html>Question 2
Easy
Write a comment that says 'Footer starts here'.
Use .
<!-- Footer starts here -->Question 3
Easy
What is wrong here?
<html><body><h1>Hi</h1></body></html>Something is missing before .
The
<!DOCTYPE html> declaration and the <head> section (with title and meta tags) are missing.Question 4
Easy
Where does go?
It is metadata.
Inside the
<head> section.Question 5
Easy
Write an HTML page with a title 'Bakery' and body containing a heading 'Welcome to our Bakery'.
Standard boilerplate with these two text values.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bakery</title>
</head>
<body>
<h1>Welcome to our Bakery</h1>
</body>
</html>Question 6
Medium
Fix this wrong nesting:
<ul>
<p><li>Apple</li></p>
<p><li>Mango</li></p>
</ul>Paragraphs should not be inside a list — and list items should be direct children of the list.
<ul>
<li>Apple</li>
<li>Mango</li>
</ul>Question 7
Medium
Does the order of meta tags in the head matter?
Think about the charset tag in particular.
Yes. The
<meta charset> tag should be among the first things in the head (within the first 1024 bytes) so the browser knows how to read the rest of the file.Question 8
Medium
Write an HTML boilerplate that includes a comment explaining what each meta tag does.
Add a comment above each meta tag.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Character encoding for all languages -->
<meta charset="UTF-8">
<!-- Make the page mobile friendly -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documented Page</title>
</head>
<body>
</body>
</html>Question 9
Medium
What is wrong with this HTML?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<body>
<h1>Hi</h1>
</body>
</html>One closing tag is missing.
The closing
</head> tag is missing. Add it before <body>.Question 10
Medium
Is this HTML valid?
<!DOCTYPE HTML>HTML is not case-sensitive for tags.
Yes. HTML is not case-sensitive, so
<!DOCTYPE HTML> is valid, but <!DOCTYPE html> (lowercase) is the standard convention.Question 11
Medium
Write a complete HTML page where the title and h1 are different: title should be 'Priya's Blog | Home' and h1 should be 'Welcome to my blog'.
Title goes in head, h1 goes in body.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Priya's Blog | Home</title>
</head>
<body>
<h1>Welcome to my blog</h1>
</body>
</html>Question 12
Hard
Why is this HTML broken?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><h1>Hi</h1></title>
</head>
<body>
</body>
</html>What kind of content belongs inside ?
The
<title> tag only accepts plain text, not other HTML tags. Remove the <h1> from inside the title. Correct version: <title>Hi</title>.Question 13
Hard
Build a complete HTML page with all the following: DOCTYPE, html with lang, head containing charset, viewport, description, author, title, and body containing a section-header comment and an h1 with 'Complete Page'.
Include every meta tag and a comment in the body.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A complete example page.">
<meta name="author" content="Aarav Kumar">
<title>Complete Page</title>
</head>
<body>
<!-- Main content -->
<h1>Complete Page</h1>
</body>
</html>Question 14
Hard
Why does this comment not work?
<!-- This is -- a bad -- comment -->Something special about double dashes inside comments.
HTML comments cannot contain
-- (two dashes) inside them. Use single dashes or other symbols instead: <!-- This is - a better - comment -->Question 15
Hard
What does a browser do if it finds this broken HTML?
<!DOCTYPE html>
<html>
<body>
<h1>Hello
</body>
</html>The h1 is not closed.
The browser is very forgiving. It will likely close the
<h1> automatically at the </body> and still show 'Hello' as a heading. But this is invalid HTML and may cause issues in complex pages.Multiple Choice Questions
MCQ 1
What should be the very first line of every HTML5 page?
Answer: C
C is correct.
C is correct.
<!DOCTYPE html> must be the very first line. It tells the browser this is an HTML5 document.MCQ 2
Which tag contains the visible content of the page?
Answer: B
B is correct. The
B is correct. The
<body> element contains everything the user sees — headings, paragraphs, images, and more.MCQ 3
Where does the tag go?
Answer: B
B is correct. The
B is correct. The
<title> tag goes inside <head>. It sets the text shown on the browser tab.MCQ 4
Which character encoding should you use?
Answer: C
C is correct. UTF-8 is the universal encoding that supports every language and symbol, including Hindi, Tamil, emoji, and more.
C is correct. UTF-8 is the universal encoding that supports every language and symbol, including Hindi, Tamil, emoji, and more.
MCQ 5
Which is the correct syntax for an HTML comment?
Answer: C
C is correct. HTML comments use
C is correct. HTML comments use
<!-- -->. The other syntaxes are from JavaScript, CSS, and Python.MCQ 6
Which tag wraps the head and body of an HTML page?
Answer: C
C is correct. The
C is correct. The
<html> element is the root of every HTML page. It wraps both the head and the body.MCQ 7
What is metadata?
Answer: B
B is correct. Metadata means 'data about data'. In HTML, metadata (like title, charset, description) describes the page but is not displayed as visible content.
B is correct. Metadata means 'data about data'. In HTML, metadata (like title, charset, description) describes the page but is not displayed as visible content.
MCQ 8
What does the viewport meta tag do?
Answer: B
B is correct. The viewport meta tag tells mobile browsers to display the page at the device's actual width, not zoomed out.
B is correct. The viewport meta tag tells mobile browsers to display the page at the device's actual width, not zoomed out.
MCQ 9
What does the lang attribute on do?
Answer: B
B is correct.
B is correct.
lang="en" tells browsers and screen readers the page is in English. It helps accessibility and search engines.MCQ 10
What is wrong with ?
Answer: B
B is correct. The correct value is
B is correct. The correct value is
UTF-8 with a hyphen. While some browsers may accept UTF8, the standard is UTF-8.MCQ 11
Which of these is valid nesting?
Answer: B
B is correct. Tags must close in the reverse order they were opened. Opening
B is correct. Tags must close in the reverse order they were opened. Opening
<b><i> means closing </i></b>.MCQ 12
Why should you indent nested HTML?
Answer: C
C is correct. Indentation is purely for readability. HTML ignores whitespace, so indentation has no effect on how the page looks — but it makes your code much easier to understand.
C is correct. Indentation is purely for readability. HTML ignores whitespace, so indentation has no effect on how the page looks — but it makes your code much easier to understand.
MCQ 13
Which meta tag helps search engines show a preview?
Answer: C
C is correct.
C is correct.
<meta name="description"> provides the text shown in Google search results below the blue link.MCQ 14
Where should comments be used in HTML?
Answer: B
B is correct. Comments are for developers, not users. Never store private information in comments — anyone can view the page source.
B is correct. Comments are for developers, not users. Never store private information in comments — anyone can view the page source.
MCQ 15
Without the DOCTYPE, what happens?
Answer: B
B is correct. Without DOCTYPE, browsers use 'quirks mode' which emulates ancient buggy HTML rendering. This can break CSS layouts in unpredictable ways.
B is correct. Without DOCTYPE, browsers use 'quirks mode' which emulates ancient buggy HTML rendering. This can break CSS layouts in unpredictable ways.
MCQ 16
What is the correct order inside the head?
Answer: B
B is correct. The charset should come first so the browser knows how to decode the rest. Then viewport, then title. This order is considered best practice.
B is correct. The charset should come first so the browser knows how to decode the rest. Then viewport, then title. This order is considered best practice.
MCQ 17
Can you put an tag inside a
tag inside a tag?
Answer: C
C is correct. The title element only accepts plain text. Other HTML tags inside it are either ignored or show as literal text in the browser tab.
C is correct. The title element only accepts plain text. Other HTML tags inside it are either ignored or show as literal text in the browser tab.
MCQ 18
What does a multi-line HTML comment look like?
Answer: B
B is correct. HTML comments can span multiple lines. Just put
B is correct. HTML comments can span multiple lines. Just put
<!-- at the start and --> at the end, and include any content between them.MCQ 19
Is HTML case-sensitive for tag names?
Answer: C
C is correct. HTML tags are case-insensitive —
C is correct. HTML tags are case-insensitive —
<P> and <p> both work. However, lowercase is the standard modern practice.MCQ 20
What happens if you put content directly inside but outside both head and body?
Answer: B
B is correct. Browsers are forgiving. They usually move stray content into the body automatically. But this is invalid HTML and you should never rely on it.
B is correct. Browsers are forgiving. They usually move stray content into the body automatically. But this is invalid HTML and you should never rely on it.
Coding Challenges
Challenge 1: Write the Perfect Boilerplate
EasyMust include DOCTYPE, lang attribute, meta charset, meta viewport, title, and a single h1.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Clean Page</title>
</head>
<body>
<h1>Clean and proper</h1>
</body>
</html>Challenge 2: Commented Sections
EasyInclude DOCTYPE, proper head, and three h2 sections with comments.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Commented Page</title>
</head>
<body>
<!-- Introduction -->
<h2>Introduction</h2>
<p>Hi, I am Ananya and I love coding.</p>
<!-- Hobbies -->
<h2>Hobbies</h2>
<p>Reading, painting, and learning HTML.</p>
<!-- Contact -->
<h2>Contact</h2>
<p>Email: ananya@example.com</p>
</body>
</html>Challenge 3: Multilingual Ready Boilerplate
MediumMust use lang="hi" on html tag and UTF-8 charset to support Devanagari.
<!DOCTYPE html>
<html lang="hi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Namaste Duniya</title>
</head>
<body>
<h1>Namaste Duniya</h1>
<p>HTML mein Hindi aasan hai.</p>
</body>
</html>Challenge 4: SEO Ready Page
MediumInclude all SEO meta tags: charset, viewport, description, author, title.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Art portfolio of Priya Sharma featuring paintings, sketches, and digital art.">
<meta name="author" content="Priya Sharma">
<title>Priya's Art Portfolio</title>
</head>
<body>
<h1>Welcome to my art portfolio</h1>
<p>Explore my collection of paintings and sketches.</p>
</body>
</html>Challenge 5: Fix the Broken Boilerplate
MediumFix DOCTYPE, lang, charset, title closing, and content placement. Also add viewport meta.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
</head>
<body>
<h1>Hello</h1>
</body>
</html>Challenge 6: Nested Structure Page
HardProper nesting and indentation required. Include full boilerplate.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Menu</title>
</head>
<body>
<h1>Our Menu</h1>
<ul>
<li>
Snacks
<ul>
<li>Samosa</li>
<li>Vada Pav</li>
</ul>
</li>
<li>
Drinks
<ul>
<li>Masala Chai</li>
<li>Mango Lassi</li>
</ul>
</li>
</ul>
</body>
</html>Challenge 7: Complete Blog Post Template
HardInclude DOCTYPE, head with charset, viewport, description, author, title, and body with commented header, content, footer sections.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="My first blog post about learning HTML from scratch.">
<meta name="author" content="Rohan Gupta">
<title>My First Blog Post</title>
</head>
<body>
<!-- ===== HEADER ===== -->
<h1>My First Blog Post</h1>
<p>By Rohan Gupta</p>
<hr>
<!-- ===== CONTENT ===== -->
<p>Learning HTML has been one of the best decisions I have made this year.</p>
<p>The boilerplate looked intimidating at first, but now I can type it out without thinking.</p>
<hr>
<!-- ===== FOOTER ===== -->
<p>Thanks for reading. See you in the next post.</p>
</body>
</html>Challenge 8: Full SEO and Mobile Ready Home Page
HardMust be SEO ready (description, proper title), mobile ready (viewport meta), and well-organized with section comments.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Home page of Vikram Singh, a young coder learning HTML, CSS, and JavaScript.">
<meta name="author" content="Vikram Singh">
<title>Vikram Singh - Home</title>
</head>
<body>
<!-- ========== HEADER ========== -->
<h1>Welcome to my site</h1>
<p>Hi, I am Vikram, a 15-year-old from Pune who loves building websites.</p>
<!-- ========== MAIN CONTENT ========== -->
<p>This site is where I share my coding journey, projects, and thoughts about technology.</p>
<p>Feel free to explore and reach out if you want to collaborate on something fun.</p>
<!-- ========== FOOTER ========== -->
<hr>
<p>Made with love and plain HTML by Vikram Singh.</p>
</body>
</html>Need to Review the Concepts?
Go back to the detailed notes for this chapter.
Read Chapter NotesWant to learn web development with a live mentor?
Explore our Frontend Masterclass