On 11/5/07, Matej Knopp <[EMAIL PROTECTED]> wrote: > > > It is true that in XML <div></div and <div/> are equivalent.
Just to be clear, I meant to write that <div></div> and <div/> are equivalent in XML. However > > XHTML (at least 1.0) has some additional rules you have to take into > > account. > > In this case the next rule applies: > > "For non-empty elements, end tags are required" > > > http://www.w3.org/TR/xhtml1/#h-4.3 > > Note that an element that is allowed to have a child node is always a > > non-empty element, even if this specific element instance has no > content. > > Therefore <div/> is invalid XHTML > > I don't believe that holds true. <div> (without closing tag) is > invalid XHTML. Because it's not well formed. There is certain > ambiguity in that section. I don't think <div> and <div/> are the same > thing. And I don't believe that if you use <div/> that means you've > ommited the end tag. It think the section is pretty clear. Please pay special attention to these two sentences: "All elements other than those declared in the DTD as EMPTY must have an end tag. Elements that are declared in the DTD as EMPTY can have an end tag *or* can use empty element shorthand" See how they make the distinction between the end tag and the empty element shorthand? And they make the distinction between EMPTY and other elements. DIV is NOT declared as an EMPTY element (because it can have child nodes). Therefore it must have an end tag. Also all the examples in section show only open > tag, not open-close. Yes, the examples do not show this unfortunately. This was probably meant to make sure that people > don't follow the html practice of using just open tags. This is already covered by 4.1 http://www.w3.org/TR/xhtml1/#h-4.1 "Essentially this means that all elements must either have closing tags or be written in a special form (as described below), and that all the elements must nest properly." XHTML files are valid XML documents, and disallowing <div/> tags would > be against it, as <tag></tag> and <tag/> are as far as I know > considered equal in xml. Equal in XML yes. And yes, XHTML files are valid XML documents. However not all XML documents are valid XHTML files, even when using XHTML tag names. However, Internet explorer doesn't understand the application/xml > header, which means that we have to serve xhtml files with text/html. > And that makes firefox use the html parser, which considers <div/> an > open tag, even though it's not true. Yes, IE does not understand application/xml. And that is why I suspect that rule 4.3 exists. So that xhtml 1.0 could be server to IE, and the result would be equivalent as serving html 4.01. Robert.