Skip to main content

What Is an Empty HTML Element?

An empty HTML element consists of only an opening tag.

In other words, empty HTML elements have no content or closing tag.


Empty elements are sometimes called self-closing elements.

Here's an illustration:

Anatomy of an empty HTML

An empty HTML element has only an opening tag

Elements with content and closing tags are called Regular HTML Elements.

Below are some of the widely used empty HTML elements.

What Is an <img> Element?

An <img> element embeds an image to a webpage.

Here's an example:

alt="Example of an image element"

Note the following:

  • src attribute specifies the image's URL.
  • The width and height attributes specify the image's dimensions.
  • An alt (alternative text) attribute is essential for accessibility. Browsers display it whenever the image fails to load. And screen readers read it to their users.
  • Suppose your image is purely decorative. In that case, provide an empty alt attribute (alt="").

What Is an <input> Element?

The <input> element creates an input field for entering data.

Here's an example:

<input type="text" name="name-of-list" />
  • The type attribute states the type of input element the browser should display.
  • The name attribute specifies the input element's name.


This article discussed what an empty HTML element is. We also saw examples of some of the widely used ones.

Join CodeSweetly Newsletter