HTML elements are the building blocks of web pages. They define the structure and content of a web page, allowing you to display text, images, links, and more. In HTML, elements are enclosed within tags, which consist of an opening tag, content, and a closing tag.
Here are some of the most common HTML elements you'll use in web development:
Headings (h1 - h6):
Headings are used to define the headings or titles of different sections on a web page.
Paragraphs (p):
The <p>
element is used to create paragraphs of text.
Links (a):
The <a>
element is used to create hyperlinks to other web pages or resources.
Lists (ul, ol, li):
Lists help organize content. <ul>
creates unordered (bulleted) lists,<ol>
creates ordered (numbered) lists, and <li>
defines list items.
Images (img):
Use the <img>
element to embed images on a web page. The <alt>
is displayed
when image is not displayed due to any reason.
In HTML, some characters are reserved for markup purposes and cannot be used as-is. To display these characters, you must use character entities or entity codes. Here are a few common specia characters:
<
for <
>
for >
&
for &
©
for ©Some HTML elements are known as "empty elements" or "self-closing elements" because they don't have closing tags. Instead, they are closed within a single tag. Here are a few common empty elements:
<img>
(Image): The <img>
element is used to embed images on a web page. It doesn't require a closing tag.<img src="image.jpg" alt="Description of the image">
<br>
(Line Break): The <br>
element is used to insert a line break within text or content. It also doesn't require a closing tag.This is a line of text.<br>This is a new line of text.
<hr>
(Horizontal Rule): The <hr>
element creates a horizontal line or thematic break on a page. Like the previous examples, it is self-closing.<hr>
Example:
You can add comments in your HTML code to make notes or explanations. Comments are not displayed on the web page and can be useful for documentation.
HTML elements are often used together to create more complex content. For example, you can combine headings, paragraphs, and links to create structured and informative web pages.
By mastering these HTML elements and understanding how to use them effectively, you can create well-structured and visually appealing web pages. In the next sections of this tutorial, we'll explore HTML attributes and more advanced topics to enhance your HTML skills.