Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which tags are can be self closing and which ones must have a closing tag in XHTML 1.0 Strict?

Tags:

xhtml

tags

strict

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?

like image 562
John Egbert Avatar asked Mar 22 '11 23:03

John Egbert


People also ask

Which HTML tags can be self closing?

↑ 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.

Which tag requires a closing tag?

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 /).

How do you close a tag in XHTML?

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.

Which tags do not need or have a closing tag?

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.


2 Answers

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.

like image 121
Gumbo Avatar answered Jan 03 '23 15:01

Gumbo


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

like image 43
Dylan Valade Avatar answered Jan 03 '23 15:01

Dylan Valade