2. HTML Basics
In this section, we will cover the foundational elements of HTML. You'll learn how to structure a web page using HTML tags and attributes.
Basic Syntax
HTML uses tags to define the structure and content of a webpage. Tags are enclosed in angle brackets, like <tag>
. Most tags come in pairs, with an opening tag and a closing tag, such as <p>
and </p>
.
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1>Welcome to HTML Basics!</h1>
<p>This is your first HTML page.</p>
</body>
</html>
HTML Tags
Tags in HTML define different parts of a webpage, like paragraphs, headings, images, and links. Some tags don't need a closing tag, like the <img>
tag.
Common HTML Tags
<html>
: Defines the entire document.<head>
: Contains metadata and other resources.<body>
: Contains the content of the page.<p>
: Defines a paragraph of text.<h1> to <h6>
: Define headings of different levels.
Attributes in HTML
Attributes provide additional information about an element. They are written inside the opening tag. For example, the <a>
tag uses the href
attribute to define the link target.
<a href="https://www.example.com">Visit Example</a>
In the next lesson, we will explore HTML elements and how to use them to build a webpage.