Reputation: 33059
Are there terms for HTML tags that differentiate between ones which should have closing tags, and ones which shouldn't?
For example, <em>
and <a>
should have accompanying </em>
and </a>
tags.
On the other hand, <br />
and <img ... />
shouldn't.
What is the first group called, and what is the second?
Upvotes: 3
Views: 1416
Reputation: 12309
According to HTML 4.01, there are three different groups when it comes to elements and tags.
I looked high and low in the specification and could find no term used to describe tags in the third grouping.
The term "empty" only says that there currently isn't any content between the tags. This applies to 1 & 2 above.
My proposal: although W3C doesn't saying anything about it, as far as I could tell, it might be possible to refer to elements like <br> as "white space elements", since they are considered to be white space, and they are elements. "White space characters", such as , are not elements, so there should be no confusion. Anyone see any problems with this? If not, maybe we should make a proposal to W3C.
Upvotes: 1
Reputation: 655189
In XHTML the document has to be well-formed. That includes that every element that has been opened with a start tag must have a corresponding end tag. Except it has no content (like other elements or text). Such elements are refered as empty elements.
And the latter ones are empty elements as they don’t have any content.
Upvotes: 5
Reputation: 25931
It should be noted that in HTML 4.01 some tags (for example, <p> and <li>) can have content, but the closing tag is optional.
The following is valid markup:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Title</title>
</head>
<body>
<p>Test
</body>
</html>
Upvotes: 1
Reputation: 1062600
I believe that <foo />
is an "empty element", as opposed to... not ;-p btw, <br />
isn't an html element - it is an xhtml element. IIRC it is supposed to be <br>
in true legacy html.
Upvotes: 7