What is HTML?
HTML stands for HyperText Markup Language. It's not a programming language — it's a markup language that tells the browser how to structure content on a web page.
Every website you've ever visited — Google, YouTube, Wikipedia, Instagram — is built with HTML at its core. Even when sites use fancy frameworks like React or Next.js, the browser ultimately renders HTML.
Think of HTML as the skeleton of a web page. CSS adds the styling (colors, fonts, layout), and JavaScript adds interactivity (clicks, animations, data). But HTML is always the foundation.
How browsers render HTML
When you visit a website, here's what happens behind the scenes:
- You type a URL (like
ramayai.com) or click a link. - Your browser sends a request to a server asking for the page.
- The server sends back an HTML file — a plain text file with tags like
<h1>and<p>. - The browser reads (parses) the HTML top to bottom, building a tree of elements called the DOM (Document Object Model).
- The browser renders the page — turning those tags into the visual content you see.
The entire process takes milliseconds. And it all starts with HTML.
HTML document structure
Every HTML page follows the same basic skeleton. Here's the minimum valid HTML document:
Let's break down each part:
<!DOCTYPE html>— Tells the browser "this is an HTML5 document." Always the very first line.<html lang="en">— The root element. Everything goes inside this. Thelangattribute helps search engines and screen readers know the language.<head>— Contains metadata: the page title (shown in the browser tab), character encoding, viewport settings for mobile. Nothing inside<head>is visible on the page itself.<meta charset="UTF-8">— Ensures the page can display any character (emojis, Hindi, Swahili, etc.).<meta name="viewport" ...>— Makes the page responsive on mobile devices.<title>— The text shown in the browser tab. Also used by search engines as the page title in results.<body>— Everything visible on the page goes here: text, images, links, buttons.
Try it yourself
Edit the code below and click Run to see your changes live. Try changing the heading text, adding a second paragraph, or changing the title.
Headings and paragraphs
HTML has six heading levels, from <h1> (biggest, most important) to <h6> (smallest). Use only one <h1> per page — it's the main title. Use <h2> for sections, <h3> for subsections, and so on.
<h1> → <h2> → <h3>) helps your page rank better in Google.
Nesting elements
HTML elements can be placed inside other elements — this is called nesting. The outer element is the parent, the inner element is the child.
The golden rule: tags must close in reverse order. If you open <p> then <strong>, you must close </strong> before </p>. Think of it like Russian nesting dolls — the innermost doll goes in first, comes out first.
Common mistakes
- Forgetting
<!DOCTYPE html>— Without it, browsers enter "quirks mode" and may render things inconsistently. Always include it as the first line. - Missing closing tags —
<p>Hellowithout</p>can cause layout bugs. Some tags like<br>and<img>don't need closing, but most do. - Wrong nesting order —
<p><strong>text</p></strong>is invalid. Always close inner tags before outer tags. - Forgetting
langon<html>— Screen readers and search engines use this. Always set it:<html lang="en">. - Not setting charset — Without
<meta charset="UTF-8">, special characters (é, ñ, ₹, 🇰🇪) may display as garbled text.
Task: Create an HTML page about yourself. Include:
- A proper
<!DOCTYPE>,<html>,<head>, and<body> - A
<title>with your name - An
<h1>with your name - An
<h2>with "About Me" - Two
<p>paragraphs describing yourself - An HTML comment with a to-do note
Use the editor above to build it — click Run to see the result!
Hint: Start with the skeleton from Section 3. Replace the title, h1, and paragraphs with your own content. Add a comment with <!-- your note --> anywhere inside the body.
Key takeaways
- HTML is the foundation of every web page. It defines structure, not style.
- Every HTML document needs
<!DOCTYPE html>,<html>,<head>, and<body>. - Tags come in pairs (opening + closing). Some are self-closing (
<br>,<img>). - Headings (
<h1>–<h6>) create hierarchy. Use one<h1>per page. - Always nest tags properly — inner tags close before outer tags.
Test your knowledge
You just wrote your first HTML.
Imagine what you'll build next.
Join the Best AI Programs — three 5-month courses, fully online, with placement assistance. Week 1 is free.
Explore our AI-era courses →
HTML comments
Comments are notes in your code that the browser ignores. They're invisible to users but helpful for developers.
Use comments to explain tricky code, leave notes for your future self, or temporarily hide elements while debugging.