π» Chapter 5: Your First HTML Program
Letβs now write our first HTML page. This simple example will help you understand how a basic HTML document is structured and how each tag works.
β Basic HTML Template
π Explanation of Each Part
Code Part | Description |
---|---|
<!DOCTYPE html> |
Declares the document type. It tells the browser that this is an HTML5 document. This must be the very first line of every HTML page. |
<html> … </html> |
This is the root tag. Everything inside this tag is considered part of the HTML page. |
<head> … </head> |
This section contains meta-information about the document. This includes the page title, links to CSS files, etc. |
<title> … </title> |
This tag defines the title of the web page, which appears in the browser tab or window title. |
<body> … </body> |
Everything you want to display on the web page (text, images, links, etc.) goes inside this tag. |
π§ Notes
-
Only the
<title>
tag is required inside the<head>
. -
HTML is not case-sensitive, but it’s best practice to write tags in lowercase.
-
Always use proper indentation to improve readability.
π§ͺ Try It Yourself
Copy and paste the above code into a text editor (like Notepad or VS Code), save it as index.html
, and open it in a browser. Youβll see an empty page, but the browser tab will show:Welcome to My Website
.