HTML Elements
An HTML element consists of a starting tag, its content, and an ending tag.
HTML Elements
The HTML element encompasses everything between the opening tag and the closing tag.
Examples of some HTML elements:
Start tag | Element content | End tag |
---|---|---|
<h1> | My First Heading | </h1> |
<p> | My first paragraph. | </p> |
<br> | none | none |
Note: Certain HTML elements, such as the <br> element, don't contain any content. We refer to these elements as empty elements. Unlike other elements, empty elements don't have an end tag.
Nested HTML Elements
HTML elements can be placed inside each other, allowing one element to hold other elements within it.
Every HTML document is made up of HTML elements that are arranged in a nested manner.
Here is an instance featuring four HTML elements: (<html>
, <body>
, <h1>
and <p>
):
Explanation
The <html>
element is like the starting point of an HTML document. It defines the entire structure of the webpage.
It begins with <html>
and an end tag </html>
.
Next, within the <html>
tag, you'll find the <body>
tag:
The <body>
tag outlines the main content of the document.
The<body>
tag has a beginning <body>
part and an ending </body>
part.
Then, inside the <body>
element there
are two other elements:
<h1>
and
<p>
:
The <h1>
element defines a heading.
It has a start tag <h1>
and an end tag </h1>
:
Never Skip the End Tag
Certain HTML elements can still be displayed correctly even if you happen to forget their closing tags:
Empty HTML Elements
HTML elements that don't contain any content are referred to as empty elements.
The <br>
tag creates a line break. It's a tag that doesn't need a closing part because it's empty.
HTML is Not Case Sensitive
HTML tags aren't affected by letter case: using <P>
is equivalent to <p>
.
While HTML rules don't insist on lowercase tags, we advises using lowercase in HTML and enforces it for stricter types like XHTML.