An HTML element is usually made up of an <opening> tag and a </closing>
tag, with the content between the two tags. An HTML element is made up of everything from the opening tag to the closing tag:
Structure of HTML elements
Opening Tag | Content | Closing Tag
-------- | ------------ | ---------
Document Heading
<br>
, <hr>
etc. have a different structure from the above. Since they do not have a closing tag, they are called empty tags.Nested HTML elements
HTML elements can be nested, meaning there can be elements within elements.
All HTML documents are made up of nested HTML elements.
The following HTML document is made up of 6 HTML elements:
Examples
HTML Element
Document Heading
This is a paragraph.
Output
This is a heading
This is a paragraph.
Example description
- The first line of the HTML document above
<!DOCTYPE html>
refers to version 5 of HTML. - It
<html>
starts with the opening tag and</html>
ends with the closing tag. <head>
The element contains additional information about the document<head>
, such as the document title, document description, etc. It starts with the tag and</head>
ends with the tag.<title>
The element contains the title or name of the document<title>
. It starts with the tag and</title>
ends with the tag.- Here
<body>
the element is the content element, that is,<body>
the main part of the document.
Document Heading
This is a paragraph
bodyPart Description:
It <body>
started with the tag and </body>
ended with the tag.
<h3>
And <p>
the two elements are content elements.
<h3>
The element represents a heading .
Document Heading
It starts with an opening tag and ends with a closing tag , and the content of this element is: Document heading.<h3>
</h3>
<p>
An element represents a paragraph .
This is a paragraph
It <p>
starts with an opening tag and </p>
ends with a closing tag, and the content of this element is: This is a paragraph.
Always use closing tags!
Examples
HTML Example
This is a paragraph
This is another paragraph
Ouput
This is a paragraph
This is another paragraph
The above example works in all browsers, because the closing tag is considered optional in HTML5.
Always use lowercase letters!
HTML tags are not case sensitive. For example, <code> <P>
and <p>
<code> have the same meaning.
Lowercase is not mandatory in HTML(5). However, the W3C recommends using lowercase, and strict documents like XHTML require lowercase.