06 January, 2016

List of HTML Self-Closing Tags

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

2 comments:

  1. 1xBet Korean Bet Sportsbook - Legalbet.co.kr
    1xbet korean is a Sportsbook owned and operated 1xbet ставки betting establishment. In the sports betting business, 1xBet is the preferred option. In 2021, the

    ReplyDelete
  2. Harrah's Hotel Reno | MapyRO
    Find 통영 출장안마 Harrah's Hotel Reno, Reno 포천 출장마사지 (Nevada) location offering business center, limo service 평택 출장샵 and parking. Mapyro features 2 hotel towers 목포 출장샵 and 3 서울특별 출장샵

    ReplyDelete