HTML coding Problems & Solutions
Explore 200 common HTML problems, markup coding exercises, validation errors, and clean syntax solutions. Click on any problem to view the common mistake and the correct standard-compliant solution.
Module 1 – HTML Fundamentals
Learn basic HTML page setups, proper DOCTYPE declarations, correct nested tags, and essential character encodings.
Ensure that closing tags match opening elements exactly and layout outlines are complete.
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello World!</h2> <!-- Mistyped closing tag -->
<p>This is a paragraph.
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is a paragraph.</p>
</body>
</html>
Ensure comments are properly closed so browsers don't skip the rest of the web document.
<!-- Missing closing tag <!-- Comment here -->
<!-- This is a correct comment -->
Close tags in the exact reverse order that they were opened (LIFO) to ensure strict validation.
<p>This is a <strong>bold</p></strong> text.
<p>This is a <strong>bold</strong> text.</p>
Always use the modern, simple `<!DOCTYPE html>` declaration to trigger standards mode in modern browsers.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html>
Declare charset metadata inside the head element before any title or other tags to avoid encoding bugs.
<meta charset="utf8"> <!-- Invalid spelling of encoding -->
<meta charset="utf-8">
Module 2 – Headings & Paragraphs
Master the correct hierarchy of H1–H6 elements, formatting rules, paragraph spacing, and line breaks.
Do not use random heading weights for styling. Heading weights should outline document structure logically.
<h1>Main title</h1>
<h4>Subheading section</h4> <!-- Skipped H2 and H3 tags -->
<h1>Main title</h1>
<h2>Subheading section</h2>
Use proper paragraph elements instead of multiple break tags to separate distinct blocks of text.
Line one.<br><br>Line two.<br><br>Line three.
<p>Line one.</p>
<p>Line two.</p>
<p>Line three.</p>
Module 3 – Links & Images
Master link attributes, relative pathways, image dimensions, and descriptive accessibility tags.
Links to external sites must include the `https://` protocol prefix, otherwise browsers treat them as local relative paths.
<a href="www.example.com">Visit Example</a>
<a href="https://www.example.com">Visit Example</a>
Always supply a descriptive `alt` attribute for all informative images to satisfy accessibility standards.
<img src="logo.png">
<img src="logo.png" alt="Company Logo">
Module 4 – Lists & Tables
Avoid broken table columns, nested listing mistakes, missing header semantic elements, and accessibility issues.
Always divide table rows into `<thead>` and `<tbody>` block wrappers for clean CSS layout target selection.
<table>
<tr><th>Name</th><th>Role</th></tr>
<tr><td>Bob</td><td>Admin</td></tr>
</table>
<table>
<thead>
<tr><th>Name</th><th>Role</th></tr>
</thead>
<tbody>
<tr><td>Bob</td><td>Admin</td></tr>
</tbody>
</table>
Module 5 – Forms
Structure valid web form groups, label-input bindings, select dropdown groupings, and input constraints.
Add the `for` attribute on a label matching the `id` of the input field to enable click-focus triggers.
<label>Username</label>
<input type="text" name="username">
<label for="username">Username</label>
<input type="text" id="username" name="username">
Radio buttons of the same select group must share the same `name` attribute to prevent selecting multiple at once.
<input type="radio" name="male_gender" value="male"> Male
<input type="radio" name="female_gender" value="female"> Female
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
Module 6 – Semantic HTML
Structure pages with semantic tags like <header>, <nav>, <main>, <section>, <article>, and <footer>.
Use proper landmark elements (header, footer, nav) instead of generic wrapper divs with styling classes.
<div class="header">Company Name</div>
<div class="nav-links"><a href="#">Home</a></div>
<header>
<h1>Company Name</h1>
<nav><a href="#">Home</a></nav>
</header>
Module 7 – Media Elements
Embed video and audio markup properties correctly, configure controllers, and arrange device fallback text descriptions.
Provide the `controls` attribute, otherwise the audio player is completely invisible and cannot be triggered.
<audio src="podcast.mp3"></audio>
<audio src="podcast.mp3" controls>Your browser does not support the audio tag.</audio>
Module 8 – Accessibility & SEO
Write SEO-optimized meta description schemas, configure viewport zoom nodes, and arrange valid landmark roles.
Supply a clear site description meta tag to populate search engine listing snippets cleanly.
<head>
<title>My Page</title>
</head>
<head>
<title>My Page</title>
<meta name="description" content="Learn semantic HTML and accessibility best practices with FreeWebsiteTemplates Academy.">
</head>