HTML Introduction — AI Lab
Learn what HTML is, how HTML Elements work, and how to create your first HTML document with simple examples and practice exercises.
AI Lab — Learn AI-Assisted HTML
Learn how to use AI effectively to generate, explain, and debug HTML code. Master prompt engineering for web development.
AI Lab — Learn AI-Assisted HTML
Welcome to the AI Lab for HTML Introduction! In this lab, you'll learn how to use AI effectively to write, understand, and debug HTML code.
What You'll Learn
- How to write effective prompts for AI to generate HTML
- How to ask AI to explain HTML code you don't understand
- How to use AI to debug HTML errors
- How to verify AI-generated code for correctness
Why AI + HTML?
AI can help you learn HTML faster by generating examples, explaining concepts, and catching mistakes. But AI is a tool, not a replacement for understanding. This lab teaches you how to use AI as a learning accelerator while building your own skills.
Prompt Lessons
Generate a Basic HTML Page
easygenerateAsk AI to generate a complete HTML5 document with a title, heading, and paragraph.
Create a valid HTML5 document with the following requirements:
1. Page title: "My First Web Page"
2. A main heading (h1) that says "Welcome to HTML"
3. A paragraph (p) that briefly introduces what HTML is
4. Use proper HTML5 document structure with <!DOCTYPE html>, <html>, <head>, and <body>
5. Set the language attribute to "en"
Return the complete HTML document.This prompt works well because it:
- Specifies the document type (HTML5) — so AI knows the standard
- Lists exact content requirements — title, heading, paragraph
- Requests proper structure — DOCTYPE, html, head, body
- Is specific — AI doesn't have to guess what you want
The numbered list makes each requirement clear and unambiguous. AI can verify each item is present in its output.
Expected Output
A complete, valid HTML5 document with proper structure.
Example Output
<!DOCTYPE html>
<html lang="en">
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>Welcome to HTML</h1>
<p>HTML (HyperText Markup Language) is the standard language for creating web pages.</p>
</body>
</html>Why it works
The prompt is structured, specific, and lists requirements as a checklist.
Common Mistakes
- Not specifying HTML5 — AI may use HTML4
- Vague instructions like "make a page"
- Missing the DOCTYPE requirement
Verification Checklist
- Has <!DOCTYPE html>
- Has <html>, <head>, <body> tags
- Title is in <head>
- Content is in <body>
- Valid HTML5 syntax
Follow-up Prompts
- Add a navigation menu
- Include CSS styling
- Add an image
Explain HTML Elements with AI
easyexplainPaste a piece of HTML code and ask AI to explain what each element does.
Explain this HTML code to me. Break down each element and describe what it does:
```html
<div class="container">
<header>
<h1>My Blog</h1>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
</header>
<main>
<article>
<h2>Post Title</h2>
<p>Post content goes here.</p>
</article>
</main>
</div>
```
For each element, explain:
1. What the tag does
2. Why it's used in this context
3. Any important attributesThis prompt works because it asks AI to break down each element, explain its purpose, and list attributes.
Expected Output
A clear, element-by-element breakdown of the HTML code with explanations.
Example Output
AI would explain: <div> is a container, <header> is the page header, <nav> contains navigation links, <main> holds primary content, <article> represents a self-contained post.Why it works
The prompt includes the actual code to explain and asks for a structured breakdown.
Common Mistakes
- Asking "what is HTML?" without providing code
- Not specifying what aspects to explain
Verification Checklist
- AI explains each element
- Explanations are clear
- Attributes are mentioned
- Context is explained
Follow-up Prompts
- How do I make this responsive?
- What CSS would style this?
Debug HTML Errors with AI
mediumdebugProvide AI with broken HTML code and an error description, then ask it to find and fix the problem.
I have an HTML page that's not displaying correctly. The image is broken and the link doesn't work.
Here's my code:
```html
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>My Photo</h1>
<img src="photo.jpg">
<a href="www.google.com">Search</a>
</body>
</html>
```
Problems I'm seeing:
1. The image shows a broken icon
2. Clicking the link goes to a wrong URL
Find the errors and provide the corrected code.This debug prompt works well because it provides: the actual code, a description of what's wrong, and specific symptoms. AI can match symptoms to common causes.
Expected Output
AI identifies: missing alt attribute on img, and missing https:// in the href. Provides corrected code.
Example Output
<img src="photo.jpg" alt="My Photo">
<a href="https://www.google.com">Search</a>Why it works
Providing both the code AND the observed symptoms gives AI maximum context to diagnose the issue.
Common Mistakes
- Saying "my code is broken" without showing the code
- Not describing what "broken" means
- Not providing error messages
Verification Checklist
- AI identifies both errors
- Corrected code is provided
- Explanations for each fix
- Code is valid HTML5
Follow-up Prompts
- How do I add more images?
- How do I create a navigation bar?