
Work through these solved and unsolved HTML exercises to practice page structure, forms, tables, embeds, and in-page links. Try each problem before reading the example solution.
Solved HTML exercises
1. Build a page from specified tags
Create a complete HTML page with a doctype, language, UTF-8 encoding, responsive viewport, and a title. In the body, put an H1 and introduction in a header, an About Us section and a three-item alphabetical service list in the main content, and email and telephone links plus a copyright notice in the footer. Make the link to more services open in a separate tab.
Example solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Website</title>
</head>
<body>
<header>
<h1>Welcome to My Website</h1>
</header>
<p>This is a sample page for the exercise.</p>
<main>
<h2>About Us</h2>
<p>We build websites and web applications.</p>
</main>
<section>
<h2>Our Services</h2>
<ol type="a">
<li>Web Design</li>
<li>Desarrollo de Aplicaciones</li>
<li>Marketing Digital</li>
</ol>
<p><a href="https://www.ejemplo.com" target="_blank">See more services</a></p>
</section>
<footer>
<a href="mailto:info@miempresa.com">Send an email</a><br>
<a href="tel:+1234567890">Call us</a><br>
© Mi Empresa, All rights reserved
</footer>
</body>
</html>
2. Build a registration form
Use fieldsets and legends to group personal details, contact details, account details, and preferences. Include first and last names, date of birth, radio buttons, email, phone, address, username, password and confirmation, a favorite-color dropdown, and a required terms checkbox. Give each control an accessible label connected by for and id. This exercise is about markup. Use sample data and add server-side validation before using a form like this on a real site.
Example solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registro de Usuario</title>
</head>
<body>
<h1>Registro de usuario</h1>
<form action="#" method="post">
<fieldset>
<legend>Personal Information</legend>
<label for="nombre">Name:</label>
<input type="text" id="nombre" name="nombre" required><br><br>
<label for="apellido">Last name:</label>
<input type="text" id="apellido" name="apellido" required><br><br>
<label for="fechaNacimiento">Date of Birth:</label>
<input type="date" id="fechaNacimiento" name="fechaNacimiento" required><br><br>
<legend>Gender:</legend>
<input type="radio" id="masculino" name="genero" value="Male" required>
<label for="masculino">Male</label><br>
<input type="radio" id="femenino" name="genero" value="Female">
<label for="femenino">Female</label><br>
<input type="radio" id="otro" name="genero" value="Other">
<label for="otro">Other</label><br><br>
</fieldset>
<fieldset>
<legend>Contact Information</legend>
<label for="email">Email Address:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="telefono">Phone Number:</label>
<input type="tel" id="telefono" name="telefono" required><br><br>
<label for="direccion">Address:</label><br>
<textarea id="direccion" name="direccion" rows="4" cols="50"></textarea><br><br>
</fieldset>
<fieldset>
<legend>Account Information</legend>
<label for="usuario">Username:</label>
<input type="text" id="usuario" name="usuario" required><br><br>
<label for="contrasena">Password:</label>
<input type="password" id="contrasena" name="contrasena" required><br><br>
<label for="confirmacionContrasena">Confirm Password:</label>
<input type="password" id="confirmacionContrasena" name="confirmacionContrasena" required><br><br>
</fieldset>
<fieldset>
<legend>Preferences</legend>
<label for="colorFavorito">Seleccionar un Favorite Color:</label>
<select id="colorFavorito" name="colorFavorito">
<option value="Red">Red</option>
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="Yellow">Yellow</option>
</select><br><br>
<input type="checkbox" id="aceptarTerminos" name="aceptarTerminos" required>
<label for="aceptarTerminos">Acepto los Terms and Conditions</label><br><br>
</fieldset>
<input type="submit" value="Register">
</form>
</body>
</html>
3. Create a table of contents
Build a table for an online book. Use a caption, column group, header, body, and footer where appropriate. Include chapter number, title, and page range. Use colspan for a heading across columns and rowspan to group several rows under one chapter. Include a chapter that only needs one row.
Example solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tabla de Contenido - Libro</title>
</head>
<body>
<table>
<caption>Book Contents</caption>
<thead>
<tr>
<th colspan="3">Chapter</th>
</tr>
<tr>
<th>Chapter</th>
<th>Chapter Title</th>
<th>Pages</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2">1</td>
<td>Introduction</td>
<td>1-5</td>
</tr>
<tr>
<td>Primeros Pasos</td>
<td>6-12</td>
</tr>
<tr>
<td rowspan="3">2</td>
<td>Conceptos Básicos</td>
<td>13-20</td>
</tr>
<tr>
<td>Avanzado</td>
<td>21-35</td>
</tr>
<tr>
<td>Ejemplos Prácticos</td>
<td>36-45</td>
</tr>
<tr>
<td>3</td>
<td>Conclusiones</td>
<td>46-50</td>
</tr>
</tbody>
</table>
</body>
</html>
4. Create a page with embedded content and anchors
Add an image with src, alt, width, and height. Embed a YouTube video in an iframe using its official embed code and give the frame a descriptive title. Add an H1, internal links to the image and video, and description and author metadata.
Example solution
<!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="Page description">
<meta name="author" content="Tu Name">
<title>Ejercicio de Imagen y Video</title>
</head>
<body>
<h1>Mi Página con Imagen y Video</h1>
<h2 id="imagen">Imagen</h2>
<p>Aquí se muestra una imagen interesante.</p>
<img src="https://www.eniun.com/wp-content/uploads/eniun-icono-detalle.svg" alt="Descripción de la imagen" width="300" height="200">
<h2 id="video">Video</h2>
<p>A continuación, puedes ver un video de YouTube.</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/09839DpTctU?si=1HYzdFGaa6L9gQx8" title="YouTube video player"
frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
<p><a href="#imagen">Ir a la Imagen</a> | <a href="#video">Ir al Video</a></p>
</body>
</html>
5. Build an HTML page from a wireframe
Recreate the structure of the original wireframe with semantic HTML. Include a header with the main heading and navigation, a main element with two sections, and a footer. Use no CSS for this exercise and validate your markup.

Example solution
<header>
<h1>TRADE</h1>
<nav>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
<button>Sign up</button>
</ul>
</nav>
</header>
<main>
<section>
<h2>Ready to get started?</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.</p>
<button>Start free trial</button>
</section>
<section>
<h2>Your Best Value Proposition</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.</p>
<div class="gallery">
<div class="gallery-individual-container">
<img src="img.jpg" alt="Description" width="300" height="300">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<a href="#">Learn more</a>
</div>
<div class="gallery-individual-container">
<img src="img.jpg" alt="Description" width="300" height="300">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<a href="#">Learn more</a>
</div>
<div class="gallery-individual-container">
<img src="img.jpg" alt="Description" width="300" height="300">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<a href="#">Learn more</a>
</div>
</div>
</section>
</main>
<footer>
<div>
<h2>TRADE</h2>
<small>© 2010 -2020</small>
<small>Privacy - Terms</small>
</div>
<div>
<h3>Product</h3>
<p>Product</p>
<p>Product</p>
<p>Product</p>
</div>
<div>
<h3>Features</h3>
<p>Feature</p>
<p>Feature</p>
<p>Feature</p>
</div>
<div>
<h3>Resources</h3>
<p>Resource</p>
<p>Resource</p>
<p>Resource</p>
</div>
<div>
<h3>Company</h3>
<p>Company</p>
<p>Company</p>
<p>Company</p>
</div>
</footer>
6. Fill in the blanks
Replace each blank with the markup needed to complete the document.
<!doctype html>
<html lang="en">
<___>
<meta charset="utf-8">
<___>Practice page</___>
</___>
<body>
<___>My HTML page</___>
<p>Welcome to my page.</p>
</body>
</html>
Answers: head, title, title, head, h1, h1.
7. Test your knowledge
Answer the questions on paper or in a text editor, then compare your answers with the table.
1. What does HTML stand for?
2. Which element creates a hyperlink?
3. Which element represents a thematic break?
4. Which element creates a numbered list?
5. Which element inserts a line break?
6. What is the current HTML standard called?
7. Which element is a level-one heading?
8. Which element embeds an image?
9. Which element marks up a paragraph?
10. Which element creates a table?
11. Which element groups controls for submission?
12. How do div and span differ by default?
13. Which element creates a dropdown list of options?
14. What is the syntax for an HTML comment?
15. What is an iframe used for?
16. What does the alt attribute provide?
17. Which element embeds video?
18. Which element can group introductory content for a page or section?
| Question | Answer |
|---|---|
| 1 | HyperText Markup Language |
| 2 | <a> |
| 3 | <hr> |
| 4 | <ol> |
| 5 | <br> |
| 6 | The HTML Living Standard. HTML5 is still widely used as a name for modern HTML. |
| 7 | <h1> |
| 8 | <img> |
| 9 | <p> |
| 10 | <table> |
| 11 | <form> |
| 12 | <div> is a generic block container. <span> is a generic inline container. |
| 13 | <select> |
| 14 | <!-- This is a comment --> |
| 15 | Embedding a separate HTML document in a page. |
| 16 | A text alternative for an image. |
| 17 | <video> |
| 18 | <header> |
HTML exercises to try on your own
8. Build a page from the wireframe
Use the wireframe to decide on the page structure, headings, links, and semantic elements. Write the HTML without adding CSS, then check it with a validator.

9. Build a page from the wireframe
Use the wireframe to decide on the page structure, headings, links, and semantic elements. Write the HTML without adding CSS, then check it with a validator.

10. Build a page from the wireframe
Use the wireframe to decide on the page structure, headings, links, and semantic elements. Write the HTML without adding CSS, then check it with a validator.
