html
The top-level element that contains the whole document tree.
Learn html as part of the HTML element system: when to use it, how it fits inside a document and what mistakes to avoid.
Main root
Every HTML document has one root element: html. It wraps the head and body and tells the browser where the document tree starts.
The root is also where global document information belongs. The lang attribute tells browsers, translation tools and assistive technology what language the page uses.
html. The root of the document. Everything else lives inside it. Syntax in context
Browsers can repair missing structure, but professional HTML should be explicit, predictable and easy to validate.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Learning HTML</title> </head> <body> <main> <h1>Learning HTML</h1> <p>The page has one clear document root.</p> </main> </body> </html>
Good versus weak
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Learning HTML</title> </head> <body> <main> <h1>Learning HTML</h1> <p>The page has one clear document root.</p> </main> </body> </html>
<head> <title>Learning HTML</title> </head> <body> <h1>Learning HTML</h1> </body>
HTML quick reference
Use these patterns when you need the syntax quickly. Each example has its own anchor, so search engines and readers can land directly on the exact pattern instead of only at the top of the lesson.
A clean version of the markup from this lesson. Use it when you need the correct HTML shape quickly.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Learning HTML</title> </head> <body> <main> <h1>Learning HTML</h1> <p>The page has one clear document root.</p> </main> </body> </html>
Meaningful markup that stays understandable before CSS and JavaScript are added.
The starting point from the practice lab. Change the HTML first, then use CSS only for presentation.
<main class="demo-card" lang="en"> <p class="label">Root idea</p> <h1>One document, one root</h1> <p>The real html element wraps the complete page. This preview shows the visible body content.</p> </main>
A complete practice snippet that shows how the HTML behaves in context.
A weak pattern from the lesson. Use it as a warning sign when reviewing real pages.
<head> <title>Learning HTML</title> </head> <body> <h1>Learning HTML</h1> </body>
A recognizable mistake you can search for and refactor.
Rules that matter
A document should have one html element that contains head and body.
Use a meaningful language value such as en or nl.
Doctype, html, head and body make the page easier to validate.
A second complete document belongs in an iframe, not inside body.
Production thinking
Beginners often ask why this is not just a div with styling. The reason is that HTML is read by browsers, search engines, screen readers and future developers. Clear meaning makes the page easier to use and maintain.
The lang attribute helps screen readers pronounce words correctly and helps translation tools understand the page.
Put the document skeleton in your base template so every page starts from a consistent, valid root.
Live code lab
Edit the HTML or CSS, then use Run to refresh the preview. The preview is isolated, so links and forms stay inside this practice area.
Mini assignment
Practice assignment
Try it yourself
Self-check
Do not only read this page. Answer these questions out loud or write the answers in your own notes. If one answer feels vague, revisit the examples before moving on.