When I put the end tag on link in head of html page, the W3C Validator shows well-formed.
But then when I validate HTML it says "Stray end link tag".
How can I validate both HTML and XML at same time?
Appendix C of XHTML 1.0 recommends syntax like
<link rel="stylesheet" href="foo.css" />
That is, the XML “self-closing” empty element tag syntax, with a space before the slash /
. The space is actually not needed any more (browsers that required it have become extinct), so you can also write
<link rel="stylesheet" href="foo.css"/>
This works on all browsers. Formally, you should not use it HTML 4.01 (see a longish explanation in Empty elements in SGML, HTML, XML, and XHTML ), and it may cause a validation error, depending on context (for link
, it does).
There's no way to make the same document both a conforming HTML 4.01 document and a conforming XHTML 1.0 document. Normally, there is no need either.
In HTML5, it's different: the “self-closing” syntax is allowed both in HTML serialization and in XML (XHTML) serialization.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.