HTML elements are the building blocks of HTML documents.
An HTML element is composed of an opening tag + content + a closing tag.
Example of an HTML element:
<p>This is a paragraph.</p>
<p>is the opening tag.
- This is a paragraph. is the content.
</p>is the closing tag.
HTML elements are capable of being nested. Meaning that one element can be placed inside another element.
The following example contains six HTML tags:
<html> <head> <title>first page</title> </head> <body> <p>This is a paragraph <br>new line</p> </body> </html>
<br> tag, and the content text are all nested inside the body element in the sample above.
Some HTML elements, such as the
<br> element, have no content and do not require an end tag. These are known as empty elements. The
tag defines a line break in the paragraph.
Another example of nested elements:
<p>This is <em>Emphasize</em> text</p> <p>This is <b>bold</b> text</p>
In the above example
<b> elements are nested inside
The following are the basic elements of an HTML page that you will come across:
tags are used to indicate a text header.
<p> tag is used to indicate a paragraph.
<hr> tag is used to indicate a horizontal ruler.
<a> (anchor) tag is used to indicate a link.
<ul> (unordered list),
<ol> (ordered list), and
<li> (list element) are used to indicate a list.
<img> tag is used to indicate an image.
<div> tag defines a division or a section in an HTML document
<span> tag is used to indicate a text span.
Want to learn more about HTML elements? Here is a useful reference guide that MDN Web Docs have created – HTML elements reference.
If you want to understand more about a website’s basic HTML structure, go here.