1. Introduction to HTML

HTML, or HyperText Markup Language, is the fundamental language used to create and structure content on the web. It allows developers to define headings, paragraphs, links, images, lists, tables, and other elements that make up a webpage. Every website, from the simplest personal page to complex web applications, starts with HTML. By using tags, HTML communicates to browsers how content should be displayed and organized. Learning HTML is the first step for anyone who wants to build websites, as it forms the backbone of all web development alongside CSS and JavaScript.

2. Basic Document Structure

Every HTML page follows a standard structure. It begins with a <!DOCTYPE html> declaration to define the HTML version, followed by the <html> root element. Inside <html>, there are two main sections: <head> and <body>. The <head> contains meta-information, the page title, and links to stylesheets or scripts, while the <body> contains the visible content such as text, images, links, and other elements. This basic structure is essential for every web page to be properly rendered by browsers.

HTML Layout
<!DOCTYPE html> <html> <head> <title>My Page</title> </head> <body> Hello World </body> </html>

3. Elements & Tags

HTML is made up of elements, which are the building blocks of a web page. Each element is represented by tags, usually written in angle brackets like <tag>. Most elements have an opening tag <tag> and a closing tag </tag>, with content placed in between. For example, a paragraph uses the <p> tag, a heading uses <h1> to <h6>, and links use <a>. Understanding elements and tags is fundamental to creating structured web pages.

Example
<h1>Welcome to HTML</h1> <p>This is a paragraph explaining the basics of HTML.</p> <a href="https://www.example.com">Visit Example</a>

4. Headings

Headings in HTML are used to define the titles and subtitles on a webpage. They range from <h1> (largest) to <h6> (smallest). Headings help organize content and improve readability. They are also important for SEO, as search engines give headings higher weight.

Example
<h1>Heading 1 - Main Title</h1> <h2>Heading 2 - Sub Title</h2> <h3>Heading 3 - Section Title</h3> <h4>Heading 4</h4> <h5>Heading 5</h5> <h6>Heading 6</h6>

5. Paragraphs

Paragraphs are used to group text content together in a block. In HTML, paragraphs are created using the <p> tag. Browsers automatically add spacing before and after paragraphs, making the text more readable.

Example
<p>This is the first paragraph of text.</p> <p>This is the second paragraph, separated from the first one.</p>

7. Images

Images are added to web pages using the <img> tag. The src attribute specifies the path to the image, and the alt attribute provides alternative text if the image cannot be displayed. You can also set width and height to control the image size.

Example
<img src="https://picsum.photos/200" alt="Random Image" width="200"> <img src="https://picsum.photos/300/150" alt="Landscape Image">

8. Lists

HTML provides two main types of lists: unordered lists and ordered lists. Unordered lists use bullets, while ordered lists use numbers. Each list item is added using the <li> tag.

Example
<!-- Unordered List --> <ul> <li>Apple</li> <li>Banana</li> <li>Cherry</li> </ul> <!-- Ordered List --> <ol> <li>First Item</li> <li>Second Item</li> <li>Third Item</li> </ol>

9. Tables

HTML tables are used to display data in rows and columns. The <table> tag creates a table, <tr> defines a table row, <th> defines a header cell, and <td> defines a standard cell.

Example
<table border="1"> <tr> <th>Name</th> <th>Age</th> <th>City</th> </tr> <tr> <td>Alex</td> <td>21</td> <td>New York</td> </tr> <tr> <td>Maria</td> <td>25</td> <td>London</td> </tr> </table>

10. Forms

HTML forms allow users to submit data to a website. The <form> tag wraps all form elements. Common input types include text, email, password, radio, checkbox, and submit buttons.

Example
<form action="#" method="post"> <label>Name:</label> <input type="text" name="name" placeholder="Enter your name"><br><br> <label>Email:</label> <input type="email" name="email" placeholder="Enter your email"><br><br> <label>Gender:</label> <input type="radio" name="gender" value="male"> Male <input type="radio" name="gender" value="female"> Female<br><br> <label>Hobbies:</label> <input type="checkbox" name="hobby" value="reading"> Reading <input type="checkbox" name="hobby" value="sports"> Sports<br><br> <input type="submit" value="Submit"> </form>

11. Audio & Video

HTML allows you to embed audio and video directly on a webpage using the <audio> and <video> tags. The controls attribute adds play, pause, and volume controls. You can also specify width, height, autoplay, and loop options.

Example
<h3>Audio Example</h3> <audio controls> <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio> <h3>Video Example</h3> <video width="320" height="240" controls> <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4"> Your browser does not support the video tag. </video>

12. Semantic Tags

Semantic tags in HTML clearly describe the purpose of the content they contain. These tags improve readability for developers and accessibility for browsers and search engines. Examples include <header>, <footer>, <article>, <section>, <nav>, and <aside>.

Example
<header> <h1>My Website</h1> </header> <nav> <a href="#">Home</a> | <a href="#">About</a> | <a href="#">Contact</a> </nav> <section> <h2>About Us</h2> <p>We are a company that creates awesome websites.</p> </section> <footer> <p>Copyright 2025</p> </footer>