Lesson 6: HTML Elements

Now a bit about the SYNTAX of HTML. An HTML page is a sequence of HTML elements.

An HTML element starts with a start tag (also called an opening tag) and ends with an end tag (also called a closing tag) and includes everything in between them.

Example: <p> is the start tag for a paragraph and </p> is the end tag.

Some tags are empty, which means they do not have a closing tag and contain only attributes. Which tag on this page is an empty tag? The <html> element defines the whole HTML document.


stamp image

The body element defines the body of the page, which is everything that is visible.

In HTML, sometimes elements are contained in other elements. For example, the body element is contained in the html element. Sometimes elements are not allows to be contained in other elements. You cannot put a level 1 heading inside a level 2 heading for example. Sometimes the same element can be contained in itself. Later you will see examples of this. When this happens it is called "nesting".

Very often things just follow in sequences. For example, paragraph elements follow each other in sequence. The syntax of HTML requires that under no circumstance can elements overlap. It is like the rules used for how parentheses can be used in math. Suppose we let the different types of brackets represent HTML tags. For example, () is a paragraph element and [] is an anchor element. Roughly speaking, elements can be placed either side-by-side, like this:
() [] ()
or inside one another, like this:
( [ ] ) or ( [ { } ] )
but you cannot overlap them like this:
( [ ) ]
So this is not allowed:
<p>blah blah <a>< ...blah blah /p> ...</a>