HTML Tutorial – Elements

An HTML element is everything from the opening tag to the closing tag.

HTML Element Syntax

  • An HTML element starts with a opening tag and ends with a closing tag
  • Most HTML elements can have attributes (You will learn about HTML attributes in the next chapter)

HTML Element Example

<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph in HTML.</p>
</body>
</html>
Try it yourself »

HTML Example Explained

The <p> and </p> are HTML tags that define a paragraph in HTML document.
The HTML content is: This is a paragraph in HTML.
The whole thing: <p>This is a paragraph in HTML.</p> is a paragraph element.

Empty HTML Elements

HTML elements with no content are called empty elements.
For example, line break tag <br> is an empty HTML element.

Empty elements can be “closed” in the opening tag like this: <br />. HTML5 does not require empty elements to be closed. But if you want stricter validation, or if you need to make your document readable by XML parsers, you must close all HTML elements properly

Use Lowercase Tags

Even though HTML is not case sensitive, but do always use lowercase tags because the World Wide Web Consortium (W3C) recommends lowercase in HTML, and demands lowercase tags in XHTML.