HTML (HyperText Markup Language) is the standard language used to create webpages.
HTML tells the browser:
Every website you visit uses HTML.
Every HTML document follows a standard structure.
index.html
<!DOCTYPE html>
<html>
<head>
<title>hello, title</title>
</head>
<body>
hello, body
</body>
</html>HTML Document

We will examine each of these parts individually.
Every HTML document begins with:
<!DOCTYPE html>This declaration tells the browser that the document uses HTML5.
Without the DOCTYPE declaration, browsers may enter compatibility mode and render pages differently.
For this reason, <!DOCTYPE html> should always be the first line of every HTML document.
<!DOCTYPE html>
<html>
...
</html>The <html> element is the root element of every webpage.
Everything on the page lives inside this tag.
<html>
<head>
</head>
<body>
</body>
</html>In modern websites, we usually specify the language:
<html lang="en">
This helps:
understand the language of the document.
The <head> element contains information about the webpage.
Most of this information is not displayed directly to users.
<head>
<title>My Website</title>
<meta charset="UTF-8">
</head>head
│
├── title
├── meta
├── link
├── script
└── style
| Element | Purpose |
|---|---|
| title | Sets the browser tab title |
| meta | Provides information about the page |
| link | Connects external resources such as CSS |
| script | Loads JavaScript |
| style | Contains CSS styles |
The <body> element contains everything visible on the webpage.
<body>
<h1>Welcome</h1>
<p>This is my website.</p>
</body>Everything users see belongs inside the body.
body
│
├── Headings
├── Paragraphs
├── Images
├── Forms
└── ButtonsMeta tags provide information about a webpage.
They help browsers and search engines understand the page.
<meta charset="UTF-8">This enables support for multiple languages and special characters.
Example:
<p>नेपाल 🇳🇵</p><meta name="viewport" content="width=device-width, initial-scale=1.0">This tells mobile devices how to display the page.
Without it:
With it:
<meta
name="description"
content="Learn HTML from beginner to advanced."
>Search engines may display this description in search results.
HTML is built using tags.
<h1>Hello</h1>| Part | Description |
|---|---|
| <h1> | Opening Tag |
| Hello | Content |
| </h1> | Closing Tag |
Most HTML elements follow this pattern.
Attributes provide additional information about an element.
Example:
<a href="https://google.com">
Google
</a>
| Part | Meaning |
|---|---|
| href | Attribute |
| https://google.com | Value |
General syntax:
<tag attribute="value">Elements can have multiple attributes.
Example:
<img
src="image.jpg"
alt="Nature"
width="300"
/>Comments are notes written for developers.
Browsers completely ignore comments.
<!-- This is a comment --><!-- Navigation Section -->
<nav>
...
</nav>Comments are useful for:
HTML tags are case-insensitive.
The following examples work the same:
<h1>Hello</h1>
<H1>Hello</H1>
<H1>HELLO</H1>Use lowercase tags:
<h1>Hello</h1>This is the modern HTML convention.
Browsers automatically ignore extra spaces and line breaks.
<p>Hello World</p>Output
Hello World
Even if content appears on multiple lines:
<p>
Hello
World
</p>Output
Hello World
The browser collapses multiple spaces into a single space.
Sometimes we want spacing and line breaks to remain exactly as written.
For this purpose, HTML provides the <pre> element.
<pre>
Hello
World
</pre>Output
Hello
World
Notice that all spacing remains unchanged.
Some characters have special meaning in HTML.
Example:
<p><h1></p>The browser interprets <h1> as an HTML tag.
To display it as plain text, we use HTML entities.
<p><h1></p>Output
<h1>
| < | < |
|---|---|
| > | > |
| & | & |
| “ | " |
| ’ | ' |
| Space | |
| © | © |
| ® | ® |
| ™ | ™ |
<p>© 2025 Samir</p>Output
© 2025 Samir
Another example:
HTML CSSOutput
HTML CSS
Every HTML page starts with the same foundation:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Page Title</title>
</head>
<body>
Content Goes Here
</body>
</html>As we continue learning HTML, everything we build will be placed inside this structure.
This structure forms the foundation of every website on the Internet.