Follow by Email

HTML5 Empty or Void elements

Most of the HTML elements have a start and an end tag that indicate where the element begins and where it ends. There is a group of elements that don’t have end tags. These elements are called empty or void and only have a start tag since they can't have any content. They must not have an end tag in HTML.

So, to summarize:
  • An empty element is one that has no content, regardless of whether it is allowed to have content in the first place.
  • void element is one that cannot have any content.

The void elements in HTML 4.01/XHTML 1.0 Strict are as follows:


 HTML5 currently adds:

To create a button with the input element, do this if you use an XHTML doctype:

    <input type="submit" value="Ok" />

And this for HTML:

    <input type="submit" value="Ok" />

Both are valid if you use HTML5.
Do not use end tag:

    <input type="submit" value="Ok" /> &lt;!&#8212; Not valid! --&gt;