HTML5 ELEMENTS CHAPTER 4
FOURTH TUTORIAL IS HTML ELEMENTS
HTML Elements
An HTML element usually
consists of a start tag and an end tag, with
the content inserted in between:
<tagname>Content goes here...</tagname>
The HTML element is
everything from the start tag to the end tag:
<p>My first paragraph.</p>
Start
tag Element content End tag
<h1> My First Heading </h1> <p> My first paragraph. </p> <br>
HTML elements with no content
are called empty elements. Empty elements do not have an end tag, such as the
<br> element (which indicates a line break).
Nested
HTML Elements
HTML elements can be nested (elements can contain elements).
All HTML documents consist of nested HTML elements.
This example contains four HTML elements:
Example
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Example Explained
The
<html>
element defines the whole document.
Inside the <html> element is the
<body>
element.
The
<body>
element defines the document body.
Inside the <body> element is two other HTML
elements: <h1> and <p>.
The
<h1>
element defines a heading.
The element content is:
My First Heading.
The
<p>
element defines a paragraph.
The element content is:
My first paragraph.
Empty HTML Elements
HTML elements with no content are called empty elements.
<!DOCTYPE html>
<html>
<body>
<p>This is a <br>
paragraph with a line break.</p>
</body>
</html>
Empty elements can be "closed" in the
opening tag like this: <br />