Bird
Raised Fist0
HTMLmarkup~10 mins

Clean HTML structure - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add the language attribute to the HTML tag.

HTML
<!DOCTYPE html>
<html [1]>
  <head>
    <meta charset="UTF-8">
    <title>My Page</title>
  </head>
  <body>
    <p>Hello, world!</p>
  </body>
</html>
Drag options to blanks, or click blank then click option'
Alanguage="en"
Blang="en"
Clang=en
Dlang='english'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'language' instead of 'lang'.
Not using quotes around the language code.
2fill in blank
medium

Complete the code to add a viewport meta tag for responsive design.

HTML
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="[1]">
  <title>Responsive Page</title>
</head>
Drag options to blanks, or click blank then click option'
Awidth=device-width, initial-scale=1.0
Bwidth=screen, scale=1
Cdevice-width=width, scale=1.0
Dwidth=device-width, scale=2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'width=screen' instead of 'width=device-width'.
Using 'scale' instead of 'initial-scale'.
3fill in blank
hard

Fix the error in the HTML structure by completing the missing closing tag.

HTML
<header>
  <h1>Welcome to my site</h1>
[1]
<main>
  <p>Content goes here.</p>
</main>
Drag options to blanks, or click blank then click option'
A</header>
B</head>
C</footer>
D</div>
Attempts:
3 left
💡 Hint
Common Mistakes
Closing with the wrong tag like or .
Forgetting to close the header tag.
4fill in blank
hard

Fill both blanks to create a semantic section with a heading.

HTML
<[1]>
  <[2]>About Us</[2]>
  <p>We build websites.</p>
</[1]>
Drag options to blanks, or click blank then click option'
Asection
Bdiv
Ch2
Dh1
Attempts:
3 left
💡 Hint
Common Mistakes
Using div instead of section.
Using h1 inside a section when a lower heading is better.
5fill in blank
hard

Fill all three blanks to create a footer with a paragraph and a link.

HTML
<footer>
  <p>[1]</p>
  <a href="[2]" aria-label="[3]">Contact us</a>
</footer>
Drag options to blanks, or click blank then click option'
A© 2024 My Website
Bmailto:contact@mywebsite.com
CEmail contact
D© 2023 My Website
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong year in the copyright.
Missing the aria-label for the link.

Practice

(1/5)
1. Which HTML tag is best to use for the main content of a webpage to keep the structure clean and semantic?
easy
A. <span>
B. <div>
C. <section>
D. <main>

Solution

  1. Step 1: Understand semantic tags purpose

    The <main> tag is designed to hold the main content of a page, making it clear and meaningful.
  2. Step 2: Compare with other tags

    While
    and <section> can group content, <main> specifically indicates the primary content, improving clarity for users and search engines.
  3. Final Answer:

    <main> -> Option D
  4. Quick Check:

    Semantic main content = <main> [OK]
Hint: Use <main> for main content, not generic <div> or <span> [OK]
Common Mistakes:
  • Using <div> instead of semantic <main>
  • Confusing <section> with main content
  • Using <span> which is inline, not structural
2. Which of the following is the correct way to declare the character set in a clean HTML document?
easy
A.
B.
C.
D.

Solution

  1. Step 1: Check correct charset attribute value

    The standard and correct value for UTF-8 encoding is 'UTF-8' with a hyphen and uppercase letters.
  2. Step 2: Validate syntax correctness

    The meta tag must be written as exactly for browsers to recognize it properly.
  3. Final Answer:

    <meta charset='UTF-8'> -> Option A
  4. Quick Check:

    Correct charset syntax = <meta charset='UTF-8'> [OK]
Hint: Use exact 'UTF-8' spelling with hyphen in meta charset [OK]
Common Mistakes:
  • Writing 'utf8' without hyphen
  • Using lowercase or missing hyphen
  • Incorrect attribute name or missing quotes
3. What will the browser display when rendering this HTML snippet?
<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset='UTF-8'>
  <title>Test</title>
</head>
<body>
  <header><h1>Welcome</h1></header>
  <main><p>Hello World</p></main>
  <footer><p>Footer text</p></footer>
</body>
</html>
medium
A. Page with header 'Welcome', paragraph 'Hello World', and footer 'Footer text'
B. Page with only 'Hello World' text
C. Page with header and footer but no main content
D. Blank page due to missing body tag

Solution

  1. Step 1: Identify semantic tags and their content

    The header contains an h1 with 'Welcome', main has a paragraph 'Hello World', and footer has 'Footer text'.
  2. Step 2: Understand browser rendering of semantic tags

    All these tags are valid and will display their content in order on the page.
  3. Final Answer:

    Page with header 'Welcome', paragraph 'Hello World', and footer 'Footer text' -> Option A
  4. Quick Check:

    Semantic tags show all content correctly [OK]
Hint: Semantic tags display their content in order on the page [OK]
Common Mistakes:
  • Assuming main content is hidden
  • Thinking body tag is missing
  • Ignoring footer content display
4. Identify the error in this HTML snippet that breaks clean structure:
<html>
<head>
  <title>Page</title>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
</head>
<body>
  <h1>Hello</h2>
  <section>Content here</section>
</body>
</html>
medium
A. Missing charset meta tag
B. Section tag cannot be inside body
C. Mismatched closing tag: </h2> instead of </h1>
D. Viewport meta tag is incorrectly placed

Solution

  1. Step 1: Check tag matching in body content

    The opening tag is <h1> but the closing tag is </h2>, which is incorrect and breaks HTML structure.
  2. Step 2: Verify other tags and meta placement

    The viewport meta tag is correctly placed in head, and section is valid inside body. Missing charset is not a structural error.
  3. Final Answer:

    Mismatched closing tag: </h2> instead of </h1> -> Option C
  4. Quick Check:

    Matching tags must open and close the same [OK]
Hint: Match opening and closing tags exactly to avoid errors [OK]
Common Mistakes:
  • Ignoring mismatched tags
  • Thinking meta tags cause structure errors
  • Believing section can't be inside body
5. You want to create a clean HTML page that is accessible and responsive. Which combination of elements and meta tags is best practice?
hard
A. <!DOCTYPE html>, <html>, <meta charset='utf8'>, <div> for all content, no viewport meta
B. <!DOCTYPE html>, <html lang='en'>, <meta charset='UTF-8'>, <meta name='viewport' content='width=device-width, initial-scale=1.0'>, semantic tags like <header>, <main>, <footer>
C. <html lang='en'>, no doctype, <span> for layout, <meta charset='UTF-8'> only
D. <!DOCTYPE html>, <html lang='en'>, no meta tags, <section> for all content

Solution

  1. Step 1: Identify required meta tags for clean structure

    Using <meta charset='UTF-8'> and viewport meta ensures correct character encoding and responsive design.
  2. Step 2: Use semantic tags and language attribute

    Including <html lang='en'> and semantic tags like <header>, <main>, <footer> improves accessibility and clarity.
  3. Final Answer:

    <!DOCTYPE html>, <html lang='en'>, <meta charset='UTF-8'>, <meta name='viewport' content='width=device-width, initial-scale=1.0'>, semantic tags like <header>, <main>, <footer> -> Option B
  4. Quick Check:

    Best practice = doctype + lang + charset + viewport + semantic tags [OK]
Hint: Always include doctype, lang, charset, viewport, and semantic tags [OK]
Common Mistakes:
  • Omitting doctype or lang attribute
  • Using non-semantic tags for all content
  • Missing viewport meta for responsiveness
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard