⚡0 XP🔥0

Introduction to HTML

Lesson 1 of 6 ⏱ 4 min read ❓ 5-question quiz ▶ Runs HTML

What HTML is, how a browser turns tags into a page, the structure of every HTML document, elements, attributes and your first web page.

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.

▶ Try it YourselfHTML
Ctrl + Enter to run

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
Tip

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 content
  • class="intro" - an attribute: extra information, always in the opening tag as name="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>
Common Mistake

<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.

▶ Try it YourselfHTML
Ctrl + Enter to run

How a browser shows your page#

  1. You type a URL. The browser asks the server for the HTML file.
  2. The browser reads the HTML from top to bottom and builds a tree of elements called the DOM (Document Object Model).
  3. It downloads the CSS, images and JavaScript the page links to.
  4. It calculates the layout and paints the page on your screen.
Did you know?

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 .html extension, 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.

Quick Quiz

Q1.

What does HTML stand for?

Q2.

Which part of an HTML page is shown inside the browser window?

Q3.

In <a href="https://vindhyaedu.com">Visit</a>, what is href?

Q4.

Which of these is an empty (void) element that has no closing tag?

Q5.

Why do we write <!DOCTYPE html> on the first line?