Which tags are can be self closing and which ones must have a closing tag in XHTML 1.0 Strict?
Example:
<br/>
<input />
Are there certain tags that must have a closing tag, can be self closing, or eigther way works in XHTML 1.0 Strict?
↑ The full list of valid self-closing tags in HTML5 is: area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, and wbr.
An opening tag begins a section of page content, and a closing tag ends it. For example, to markup a section of text as a paragraph, you would open the paragraph with an opening paragraph tag <p> and close it with a closing paragraph tag </p> (closing tags always proceed the element with a /).
XHTML tags must be closed with a closing tag or a trailing slash. Examples: <p>Some text</p>, <br />. In HTML, closing tags and trailing slashes are not required (but they are acceptable). XHTML does not permit overlapping nested tag structures.
The void elements or singleton tags in HTML don't require a closing tag to be valid. These elements are usually ones that either stand alone on the page or where the end of their contents is obvious from the context of the page itself.
Every element, that’s content model is EMPTY
in the XHTML 1.0 Strict DTD (i.e. <!ELEMENT element-name EMPTY>
), is an empty element and “must either have an end tag or the start tag must end with />
.” Namely it’s base
, meta
, link
, hr
, br
, param
, img
, area
, and input
. Every other element must have an end tag.
You are asking about "EMPTY Elements" including <hr /> <input /> <img /> <meta /> <link />
which can all be closed in a single tag. Non-empty elements which should contain text or sub-elements could technically be closed this way if they have no child or text but you are not supposed to do it. For example <p></p>
should not be <p />
but that could pass strict validation.
http://www.w3.org/TR/xhtml1/#guidelines
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With