Lesson 1 of 55
HTMLIntroduction to HTML
15 min
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 1 of 55
HTML15 min
Keep these ideas in mind as you work through the lesson.
HTML (HyperText Markup Language) is the standard language used to create web pages. Every website you visit is built using HTML in some form.
HTML is responsible for the structure of a page. It tells the browser what each piece of content represents, such as a heading, paragraph, image, button, or link.
Think about a newspaper:
HTML works in a similar way by organizing content into meaningful parts.
When building websites, three technologies usually work together.
| Technology | Purpose |
|---|---|
| HTML | Creates the structure and content |
| CSS | Controls the appearance and layout |
| JavaScript | Adds interactivity and behavior |
For example, on a login page:
HTML is made up of tags.
Example:
<p>Hello World</p>
This contains:
<p>Hello World</p>Together they form an HTML element.
Another example:
<h1>Welcome</h1>
Here, the browser understands that the text is a main heading.
HTML elements can be placed inside other elements.
<section>
<h2>About Me</h2>
<p>I am learning HTML.</p>
</section>
In this example:
<section> element contains two child elements.This is called nesting.
Proper nesting keeps code organized and easier to read.
Some HTML elements do not contain content and therefore do not require a closing tag.
Examples:
<br>
<hr>
<img src="photo.jpg" alt="Photo">
Common examples include:
<br> for a line break<hr> for a horizontal line<img> for displaying images<meta> for page informationHTML has evolved over the years. The latest major version is HTML5.
HTML5 introduced many useful features, including:
<header>, <main>, and <footer>Modern websites are built using HTML5.
HTML is the foundation of web development.
A good understanding of HTML helps you:
Even experienced developers spend a significant amount of time working with HTML.
Every HTML page follows a standard structure.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My First Page</title>
</head>
<body>
<h1>Hello, HTML!</h1>
<p>Welcome to the web.</p>
</body>
</html>
Understanding this structure is important because it forms the foundation of every webpage.
<!DOCTYPE html>
The doctype tells the browser that the document uses HTML5.
Without it, browsers may display pages differently.
<html lang="en">
This is the root element of the document.
The lang attribute specifies the language used on the page.
Benefits include:
<head>
</head>
The head contains information about the page.
Common items placed inside the head include:
<meta charset="UTF-8">
This allows the browser to display text correctly, including special characters and multiple languages.
<title>My First Page</title>
The title appears:
<body>
</body>
Everything visible on the page goes inside the body.
Examples include:
HTML provides six levels of headings.
<h1>Main Heading</h1>
<h2>Section Heading</h2>
<h3>Subsection Heading</h3>
<h4>Heading Level 4</h4>
<h5>Heading Level 5</h5>
<h6>Heading Level 6</h6>
Good practices:
<h1> for the main page title.<h2> for major sections.<h3> for topics inside a section.Headings should describe the structure of the content, not just change text size.
Paragraphs are created using the <p> element.
<p>This is a paragraph.</p>
A paragraph is used for blocks of text.
Browsers automatically add spacing between paragraphs.
Comments are notes written for developers.
<!-- This is a comment -->
Comments are useful for:
Comments are not displayed on the webpage.
Attributes provide additional information about an element.
Example:
<a href="https://example.com">Visit Website</a>
In this example:
href is an attribute.Another example:
<img src="cat.jpg" alt="A cat">
Here:
src specifies the image location.alt provides alternative text.Attributes are written inside the opening tag.
Semantic elements describe the purpose of content.
Example:
<header>
<h1>My Blog</h1>
</header>
Common semantic elements:
<header><nav><main><section><article><footer>Benefits:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Student Portfolio</title>
</head>
<body>
<h1>Mohit's Portfolio</h1>
<h2>About Me</h2>
<p>I am learning HTML and web development.</p>
<h2>Projects</h2>
<p>This is my first website.</p>
</body>
</html>
This page includes:
Incorrect:
<p>Hello World
Correct:
<p>Hello World</p>
Incorrect:
<html>
Correct:
<!DOCTYPE html>
<html>
Headings should be used to organize content, not simply to make text larger.
After completing this lesson, you should understand:
Create a webpage that contains:
<h1> heading.<h2> headings.Open the page in your browser and verify that everything appears correctly.
In the next lesson, you will learn how to work with: