#4 HTML Elements

An HTML element is defined by a start tag, some content, and an end tag.

HTML Elements

The HTML element is everything from the start tag to the end tag:

<tagname>Content goes here...</tagname>

Examples of some HTML elements:

<h1>My First Heading</h1>
<p>My first paragraph.</p>
Start tagElement contentEnd tag

My First Heading

My first paragraph.


Note: Some HTML elements have no content (like the
element). These elements are called empty elements. Empty elements do not have an end tag!

Nested HTML Elements

See the Pen nested html tag by Arpit (@soniarpit) on CodePen.

The <html> element is the root element and it defines the whole HTML document.

It has a start tag <html> and an end tag </html>.

Then, inside the <html> element there is a <body> element

The <body> element defines the document’s body.

It has a start tag <body> and an end tag </body>.

Then, inside the <body> element there are two other elements: <h1> and <p>

Then, inside <h1> tag there is <i> (italic) tag.

Inside <p> tag there is <u> (underline) tag.

Never Skip the End Tag

Some HTML elements will display correctly, even if you forget the end tag. See the following example how we don’t get desired output.

See the Pen incomplete tag html by Arpit (@soniarpit) on CodePen.

However, never rely on this! Unexpected results and errors may occur if you forget the end tag!

Empty HTML Elements

HTML elements with no content are called empty elements.

The <br> tag defines a line break, and is an empty element without a closing tag.

See the Pen br tag by Arpit (@soniarpit) on CodePen.

HTML is Not Case Sensitive

HTML tags are not case sensitive: <P> means the same as <p>.

The HTML standard does not require lowercase tags, but W3C recommends lowercase in HTML and demands lowercase for stricter document types like XHTML.

Hope you like this tutorial. Try your self and happy coding :)

Previous: #3 HTML Basic

Next: #5 HTML Attributes