What is HTML?#
HTML (HyperText Markup Language) describes the structure of a web page. It tells the browser "this is a heading", "this is a paragraph", "this is an image", "this is a link".
A website is built from three languages that work together:
| Language | Job | Example |
|---|---|---|
| HTML | Structure and content | headings, paragraphs, images, forms |
| CSS | Presentation (look) | colours, fonts, spacing, layout |
| JavaScript | Behaviour | clicks, pop-ups, calculations, loading data |
HTML किसी web page का ढांचा (structure) है - जैसे घर की दीवारें और कमरे। CSS उस घर का रंग-रोगन और सजावट है, और JavaScript बिजली की wiring जैसा है जिससे चीज़ें काम करती हैं (button दबाओ तो कुछ हो)।
HTML is not a programming language - it has no loops or conditions. It is a markup language: you wrap content in tags.
Your first web page#
Press Run to see the page. Then change the text and run again.
The structure of every HTML document#
| Part | Meaning |
|---|---|
<!DOCTYPE html> |
"This is an HTML5 document" - always the first line |
<html lang="en"> |
the root element; lang helps screen readers and Google |
<head> |
information about the page: title, character set, CSS, SEO tags |
<meta charset="utf-8"> |
lets the page show every language - English, हिंदी, emoji |
<title> |
the text on the browser tab and in Google results |
<body> |
everything the visitor sees |
Add <meta name="viewport" content="width=device-width, initial-scale=1"> in the <head> of every real page. Without it, phones show the page zoomed-out and tiny.
Elements, tags and attributes#
An element is an opening tag, content and a closing tag:
<p class="intro">Learning HTML is easy.</p>
<p>- opening tag,</p>- closing tag (note the/)Learning HTML is easy.- the contentclass="intro"- an attribute: extra information, always in the opening tag asname="value"
Some elements have no content and no closing tag - they are called void elements: <br>, <hr>, <img>, <input>, <meta>, <link>.
Elements can be nested - one inside another. Close them in the reverse order you opened them:
<p>This is <strong>very <em>important</em></strong>.</p>
<p><strong>Hello</p></strong> is wrong - the tags cross each other. Close the inner tag first: <p><strong>Hello</strong></p>.
Comments#
Comments are notes for developers. The browser ignores them.
How a browser shows your page#
- You type a URL. The browser asks the server for the HTML file.
- The browser reads the HTML from top to bottom and builds a tree of elements called the DOM (Document Object Model).
- It downloads the CSS, images and JavaScript the page links to.
- It calculates the layout and paints the page on your screen.
Right-click any web page and choose View page source (or press Ctrl + U) to see its HTML. Press F12 to open Developer Tools and inspect any element - the best way to learn from real websites.
Tools you need#
- A browser - Chrome, Edge or Firefox.
- A code editor - VS Code is free. The Live Server extension reloads the page every time you save.
- Save files with the
.htmlextension, e.g.index.html, and double-click to open them in the browser.
Summary#
- HTML gives a page its structure; CSS styles it; JavaScript makes it interactive.
- Every page has
<!DOCTYPE html>,<html>,<head>and<body>. - Elements are made of tags; attributes add extra information in the opening tag.
- Close nested tags in reverse order; void elements like
<br>and<img>have no closing tag.