An HTML element is defined by starting tag, some contents in the middle, and the closing tag.
Some Examples:
Start Tag | Content | End Tag |
---|---|---|
<h1> | This is heading 1 content | </h1> |
<title> | This is a title content | </title> |
<p> | This is a paragraph content | </p> |
<br/> | none | none |
In the above table, you can see that HTML content begins with start and end tag. For example: <h1> … </h1>, <title> … </title>, <p>…</p>. Some HTML elements don’t need closing tag like <br />, <img… />, <hr />. These elements are called void elements.
Nested HTML Elements:
You are allowed to use one HTML element inside another HTML element. An HTML documents contain nested HTML elements.
The below example contains the following elements <html>, <head>, <title>, <body>, <h1>, and <p>.
You can see that the elements are used inside other elements. These are called nested elements. <html> is the root elements.
Example:
<!DOCTYPE html>
<html>
<head>
<title>My Heading</title>
</head>
<body>
<h1>Heading</h1>
<p>First Paragraph.</p>
</body>
</html>
Example Described:
An HTML document starts with root element <html>, which has start tag <html> and end tag </html>. Inside the <html> element, there are <head> element and <body> element.
<head>
<title>My Heading</title>
</head>
<body>
<h1>Heading</h1>
<p>First Paragraph.</p>
</body>
Let first go through <head> element . An <head> element consist of another element <title> with its contents and closing tag. Inside the <title> tag, you will write the document title.
<body> element is nested by another two elements <h1> and <p>. <h1> elements is used to write the heading of the document and <p> element is used for the document paragraph.
Output:
You may be interested in the following topics:
- HTML Favicon
- HTML Links
- HTML Colors
- HTML Quotations
- HTML Comments
- HTML Formatting
- HTML Styles
- HTML Paragraph
- HTML Headings
- HTML Attributes
- HTML Elements
- What is HTML?