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.

Key point:
HTML describes the structure of content — headings, paragraphs, images, links, forms. The browser reads the HTML and renders it visually.

How browsers render HTML

When you visit a website, here's what happens behind the scenes:

  1. You type a URL (like ramayai.com) or click a link.
  2. Your browser sends a request to a server asking for the page.
  3. The server sends back an HTML file — a plain text file with tags like <h1> and <p>.
  4. The browser reads (parses) the HTML top to bottom, building a tree of elements called the DOM (Document Object Model).
  5. 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:

index.html The basic HTML skeleton

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. The lang attribute 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.

✏️ Try It Yourself — Edit & Run
Preview

Tags and elements

HTML uses tags to mark up content. Most tags come in pairs: an opening tag and a closing tag.

tags.html Opening and closing tags

An element = opening tag + content + closing tag. So <p>Hello</p> is a paragraph element. Some elements like <br> and <img> are self-closing — they don't wrap content.

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.

✏️ Try It Yourself — Headings
Preview
SEO tip:
Search engines use headings to understand your page structure. A clear hierarchy (<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.

nesting.html Elements inside elements

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.

HTML comments

Comments are notes in your code that the browser ignores. They're invisible to users but helpful for developers.

comments.html Invisible notes in your code

Use comments to explain tricky code, leave notes for your future self, or temporarily hide elements while debugging.

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>Hello without </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 lang on <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.
Mini Challenge: Build Your First Page

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

Question 1 of 5
What does HTML stand for?
Question 2 of 5
What goes inside the <head> element?
Question 3 of 5
Which tag should appear only once per page and represents the main title?
Question 4 of 5
What is the correct nesting order?
Question 5 of 5
What does <!DOCTYPE html> do?
0
/5
Great start! You understand HTML basics.
Africa & India's Best AI Academy
🤖 AI-first 🎓 Placement Assistance

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 →