Introduction to HTML
Learn the foundation of every website — from basic structure to your first web page.
What is HTML?
HTML (HyperText Markup Language) is the standard markup language used to create and design web pages. It describes the structure of a web page using a series of elements, which tell the browser how to display the content.
The term HyperText refers to the ability to link various web pages together, while Markup Language indicates that it uses tags to mark elements within the text.
HTML was created by Tim Berners-Lee in 1991. The latest version is HTML5, which introduced many new features like semantic elements, audio/video support, canvas, and more.
Key Facts about HTML
- HTML stands for HyperText Markup Language
- HTML describes the structure of a Web page
- HTML consists of a series of elements
- HTML elements tell the browser how to display the content
- HTML file extension is
.htmlor.htm - HTML can be created and edited using any text editor like Notepad, VS Code, Sublime Text, etc.
History of HTML & Versions
HTML has evolved significantly since its creation in 1991. Here is a brief timeline of official HTML versions:
HTML Version Timeline
HTML Editors
HTML files can be created using any text editor. However, specialized code editors provide features like syntax highlighting, auto-completion, and error detection.
Most popular free code editor by Microsoft. IntelliSense, extensions, integrated terminal, and Git support.
Simple text editor built into Windows. Great for beginners to understand raw HTML.
Lightweight and fast editor with powerful shortcuts and a distraction-free writing mode.
Free source code editor for Windows. Supports syntax highlighting for many languages.
Basic Structure of an HTML Page
Every HTML page follows a standard structure. Here is the basic skeleton of an HTML document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Web Page</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is my first web page.</p>
</body>
</html>Explanation of Each Part
<!DOCTYPE html>Declares that this document is an HTML5 document. Must be the very first line.<html>The root element. All other elements are contained inside this.<head>Contains meta-information about the page (title, charset, stylesheets). NOT displayed on screen.<meta charset="UTF-8">Character encoding (UTF-8 supports most global characters and symbols).<meta name="viewport">Makes the web page responsive on mobile devices.<title>Sets the title shown in the browser tab.<body>Contains all the visible content (text, images, links, tables, forms, etc.).<h1>Defines the main heading of the page.<p>Defines a paragraph of text.HTML Tags & Syntax
HTML uses tags to define elements. Tags are written inside angle brackets < >. Most tags come in pairs — an opening tag and a closing tag.
<!-- Opening and closing tags with content -->
<p>This is a paragraph.</p>
<!-- Self-closing tags (no separate closing tag required) -->
<br>
<hr>
<img src="photo.jpg" alt="A photo">Tag Syntax Rules
<tagname> — Starts an element</tagname> — Ends an element (note the forward slash /)<br>, <img>, <hr> — Elements without text contentHTML Attributes
Attributes provide additional information about HTML elements. They are always specified in the opening tag and usually come in name="value" pairs.
<!-- href attribute for hyperlinks -->
<a href="https://knobly.com" target="_blank">Visit Knobly</a>
<!-- src and alt attributes for images -->
<img src="flower.jpg" alt="Beautiful Rose" width="300" height="200">
<!-- id and class attributes for styling and JS -->
<div id="header-container" class="main-card">
<p class="highlight-text">Styled text</p>
</div>
<!-- title attribute for tooltip on hover -->
<p title="Click to view details">Hover over this text!</p>| Attribute | Description | Used With |
|---|---|---|
href | Specifies the URL of a hyperlink | <a> |
src | Specifies the path to an image or media file | <img>, <script>, <audio> |
alt | Alternative text if image cannot load | <img> |
width / height | Sets width and height in pixels or % | <img>, <table>, <iframe> |
id | Unique identifier for an element on the page | All elements |
class | CSS class name(s) for styling and grouping | All elements |
style | Inline CSS styles applied directly | All elements |
title | Extra info displayed as a tooltip on hover | All elements |
target | Where to open link (_blank = new browser tab) | <a> |
type | Type of input element (text, email, password, etc.) | <input>, <button> |
placeholder | Hint text shown inside empty input fields | <input>, <textarea> |
required | Specifies that field must be filled before submitting | <input>, <select> |
Common HTML Tags Quick Reference
A quick reference of the most frequently used basic HTML tags:
<h1> - <h6>Headings (h1 = largest, h6 = smallest)
<p>Paragraph text block
<a>Hyperlink to another page or section
<img>Embeds an image
<br>Line break (single space line)
<hr>Horizontal divider line
<b> / <strong>Bold text / Important emphasis
<i> / <em>Italic text / Emphasized text
<u>Underlined text
<ul> / <ol>Unordered (bullet) and Ordered (numbered) lists
<li>List item within ul or ol
<div>Block-level container element
<span>Inline container element
<table>Tabular data grid
<form>User input submission form
<input>Interactive input control
<button>Clickable action button
<textarea>Multi-line text input field
HTML Comments
Comments in HTML are used to insert notes in your code that are NOT displayed in the browser. They help developers understand and document the code.
<!-- यह एक सिंगल-लाइन टिप्पणी है -->
<p>यह पैराग्राफ ब्राउज़र पर दिखाई देगा।</p>
<!--
यह एक बहु-पंक्ति टिप्पणी है।
यह कई लाइनों तक फैल सकती है।
-->
<!-- <p>यह पैराग्राफ छुपा हुआ है (commented out)।</p> -->Creating Your First Web Page
Follow these 4 simple steps to create and run your very first HTML page locally:
Step-by-Step Guide
Open Notepad on Windows, TextEdit on Mac, or install VS Code.
Type or paste the complete HTML document skeleton into your editor.
Save as index.html. Ensure "Save as type" is set to "All Files (*.*)".
Double-click the saved file to open it in Chrome, Edge, Firefox, or Safari!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My First Website</title>
</head>
<body>
<h1>Welcome to My First Web Page!</h1>
<p>I am learning HTML on Knobly Web Platform.</p>
<hr>
<h2>About Me</h2>
<p>I am a web development student preparing for O-Level M2-R5 exam.</p>
<h2>My Hobbies</h2>
<ul>
<li>Coding</li>
<li>Learning Web Design</li>
<li>Reading</li>
</ul>
<p><a href="https://knobly.com" target="_blank">Visit Knobly</a></p>
</body>
</html>HTML5 New Features
HTML5 is the modern web standard. It introduced new semantic elements, native multimedia tags, and advanced form inputs:
New Semantic Elements
<header>— Top header of page or section<nav>— Navigation link container<main>— Primary content area of document<section>— Thematic section of content<article>— Self-contained article or blog post<aside>— Sidebar or tangential content<footer>— Footer with copyright and links<figure>— Illustrated figure with captionNative Multimedia Elements
<audio> — Play audio directly in the browser<video> — Play video files natively without third-party plugins<canvas> — Draw dynamic 2D/3D graphics with JavaScript<svg> — Render crisp scalable vector graphics at any screen sizeNew Form Input Types
type="email"Email validationtype="url"URL validationtype="number"Numeric countertype="date"Date pickertype="time"Time pickertype="color"Color pickertype="range"Slider controltype="search"Search inputHTML vs CSS vs JavaScript
Modern web pages are built using three foundational technologies that work together harmoniously:
HTML
Structure & Content
Defines what appears on the page — headings, paragraphs, images, links, forms
CSS
Styling & Design
Defines how things look — colors, typography, layout, animations, responsive grid
JavaScript
Behavior & Logic
Defines what happens — click events, validation, animations, API requests
Element and Tag Reference →
Complete reference covering all HTML tags with examples and practice