List of HTML Self-Closing Tags

List of Self-Closing Tags in HTML

This page is a list of HTML elements that do not have a closing tag. They are also called {self-closing tag, empty tag, void element, singleton tag}.
Here’s a complete list of self-closing tags for HTML 5.

<area />
<base />
<br />
<col />
<command />
<embed />
<hr />
<img />
<input />
<keygen />
<link />
<meta />
<param />
<source />
<track />
<wbr />

The space before the slash is optional.

Is the Ending Slash Optional?

  • HTML5: the slash is optional.
  • HTML4: the slash is technically invalid. However, it’s accepted by W3C’s HTML validator.
  • XHTML: The slash is REQUIRED.

I recommend to always add the slash. Because, it provides a visual clue of non-closing tags. It’s also convenient if you write simples scripts to check your HTML, without a lookup table or using heavy HTML parser.

XHTML Supports Self-Closing Syntax for All Tags

In XML/XHTML, every tag can be self-closed by the ending slash <… />. When you test it, you have to make sure the server is sending the correct Internet media type as XHTML (⁖ application/xhtml+xml), otherwise browsers will treat it as HTML, regardless of the DOCTYPE in your file.

I do NOT recommend self-closing for normal tags.

Reference:

Thank you. #keepSharing

Page Views (1851)

5068 Total Views 2 Views Today
Share Love & Support:

About Pratik Butani

Pratik Butani is Enthusiastic Android Application Developer, Speaker at Google Developer Group – Rajkot, All time Learner of new things, Googler, Eager to Help IT Peoples. He also like to TEACH Android to New Learner and Share his knowledge to them. He is currently working as a Senior Android Developer at Soham ERP Solutions Pvt. Ltd. – Ahmedabad. He is working with Android Development since 2013 and now Flutter is on going.

Comment Your Suggestion or Appreciation:

Loading Facebook Comments ...

2 Comments

  1. Pingback: 《Python web开发》笔记 一:网页开发基础 | 秀品折

  2. Pingback: 《Python web开发》笔记 一:网页开发基础 | 神刀安全网

Leave a Reply

Your email address will not be published. Required fields are marked *