Article Title
Article content...
Your complete guide to HTML from basics to advanced concepts. Learn the foundation of web development.
Start LearningHTML is the backbone of every website on the internet
HTML (HyperText Markup Language) is the standard markup language used to create and structure pages on the web. It tells a web browser what content exists and gives that content a hierarchical structure the browser can display and other tools
Supported by all browsers and devices, making it essential for web development.
HTML has a simple syntax that beginners can quickly grasp and start using.
Understanding the fundamentals of HTML
HTML (HyperText Markup Language) is the standard markup language for creating web pages.
HTML was created by Tim Berners-Lee in 1991 and has evolved through multiple versions, with HTML5 as the current standard.
Elements are the building blocks of HTML, consisting of tags, attributes, and content. And HTML element = opening tag + content + closing tag.
<tagname attribute="value">Content</tagname>
HTML headings are defined with the <h1> to <h6> tags, with <h1> being the most important and <h6> the least important.
<h1>This is H1</h1>
<h2>This is H2</h2>
<h3>This is H3</h3>
<h4>This is H4</h4>
<h5>This is H5</h5>
<h6>This is H6</h6>
The <p> tag defines a paragraph of text. Browsers automatically add some margin before and after each paragraph.
<p>This is a paragraph of text in HTML.</p>
This is a paragraph of text in HTML.
The <br> tag inserts a single line break, while <hr> defines a thematic break or horizontal rule.
Hello<br>World
<hr>
This is after a horizontal line
HTML provides various tags for formatting text, including bold, italic, strong, emphasis, subscript, and superscript.
<p><b>Bold</b> and <i>Italic</i></p>
<p><strong>Strong</strong> and <em>Emphasis</em></p>
<p>Water is H<sub>2</sub>O and 2<sup>3</sup>=8</p>
Bold and Italic
Strong and Emphasis
Water is H2O and 23=8
The <a> tag defines a hyperlink, which is used to link from one page to another. The href attribute specifies the link's destination.
<a href="https://www.google.com" target="_blank">Go to Google</a>
(clickable, opens in new tab)
The <img> tag is used to embed an image in an HTML page. The src attribute specifies the path to the image, and the alt attribute provides alternative text.
<img src="https://via.placeholder.com/150" alt="Sample Image">
HTML lists allow web developers to group a set of related items. <ul> defines an unordered list, <ol> defines an ordered list.
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Orange</li>
</ul>
<ol>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ol>
HTML tables allow web developers to arrange data into rows and columns. A table is defined with the <table> tag.
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Abi</td>
<td>22</td>
</tr>
<tr>
<td>Kumar</td>
<td>25</td>
</tr>
</table>
| Name | Age |
|---|---|
| Abi | 22 |
| Kumar | 25 |
HTML forms are used to collect user input. The <form> element defines a form that contains interactive controls.
<form>
<label for="name">Name:</label>
<input type="text" id="name"><br><br>
<label for="email">Email:</label>
<input type="email" id="email"><br><br>
<button type="submit">Submit</button>
</form>
A simple form with:
HTML provides elements for embedding media content, such as video and audio, directly into web pages.
<video width="300" controls>
<source src="sample.mp4" type="video/mp4">
Your browser does not support video.
</video>
<audio controls>
<source src="sample.mp3" type="audio/mp3">
Your browser does not support audio.
</audio>
Understanding the components of an HTML document
The foundation of every HTML document with essential elements and structure.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
The head contains meta information about the document, not displayed on the page.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="author" content="John Doe">
<title>Document Title</title>
<link rel="stylesheet" href="styles.css">
<style>
/* CSS styles */
</style>
</head>
The body contains the visible content of the web page.
<body>
<header>
<h1>Website Title</h1>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
</nav>
</header>
<main>
<article>
<h2>Article Title</h2>
<p>Article content...</p>
</article>
</main>
<footer>
<p>© 2023 My Website</p>
</footer>
</body>
Article content...
HTML5 introduced semantic elements that clearly define different parts of a web page.
<header> <!-- Top section -->
<nav> <!-- Navigation -->
<main> <!-- Main content -->
<section> <!-- Section of content -->
<article> <!-- Self-contained content -->
<aside> <!-- Side content -->
<footer> <!-- Bottom section -->
Comments help document code, and special characters display reserved symbols.
<!-- This is a comment -->
<!--
Multi-line comments
can span several lines
-->
<p>Copyright © 2023</p>
<p>Price: €10.99</p>
<p>5 > 3 & 3 < 5</p>
Copyright © 2023
Price: €10.99
5 > 3 & 3 < 5
The DOM represents the document as a tree structure of objects.
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Heading</h1>
<p>Paragraph</p>
</body>
</html>
Modern HTML features and APIs
Embed audio, video, and graphics directly into your web pages.
<!-- Audio -->
<audio controls>
<source src="audio.mp3" type="audio/mp3">
</audio>
<!-- Video -->
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
</video>
Audio Player: 🎵 Shows play/pause controls for audio files
Video Player: 🎥 Shows video with play/pause/volume controls
Leverage powerful browser APIs for enhanced functionality.
<!-- Geolocation API -->
<button onclick="getLocation()">Get Location</button>
<p id="demo"></p>
<script>
function getLocation() {
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
document.getElementById("demo").innerText =
"Latitude: " + position.coords.latitude +
", Longitude: " + position.coords.longitude;
});
} else {
document.getElementById("demo").innerText = "Geolocation not supported";
}
}
</script>
<button onclick="saveData()">Save Name</button>
<input type="text" id="username">
<p id="showName"></p>
<script>
function saveData(){
let name = document.getElementById('username').value;
localStorage.setItem('name', name);
document.getElementById('showName').innerText = "Saved Name: " + name;
}
</script>
Modern HTML features that enhance user experience and performance.
<!-- Lazy loading images -->
<img src="image.jpg" loading="lazy" alt="...">
<!-- Contenteditable attribute -->
<div contenteditable="true">
Editable content
</div>
<!-- Details & Summary -->
<details>
<summary>Click to expand</summary>
Hidden content revealed
</details>
Contenteditable:
Details & Summary:
Hidden content revealed! This is a native HTML accordion without JavaScript.
Special characters can be added using entities for reserved symbols.
<p>Less than: <, Greater than: >, Copyright: ©</p>
<p>Ampersand: &, Euro: €, Trademark: ™</p>
<p>Non-breaking space example</p>
Less than: <, Greater than: >, Copyright: ©
Ampersand: &, Euro: €, Trademark: ™
Non-breaking space example (spaces won't break)
Embed another webpage or content within your page.
<iframe src="https://www.example.com" width="400" height="300"></iframe>
<!-- YouTube video embed -->
<iframe width="560" height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
Embedded Content:
✅ Output: Embedded website or content in your page.
Create dynamic graphics and vector images directly in HTML.
<!-- Canvas -->
<canvas id="myCanvas" width="200" height="100"></canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(20, 20, 150, 50);
</script>
<!-- SVG -->
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>
Canvas:
SVG:
✅ Output: Canvas creates bitmap graphics, SVG creates scalable vector graphics.