Question

I have the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd"

    [
        <!ATTLIST a extra-attr CDATA #IMPLIED>
    ]>

<html>
  <head>
    <title>Title</title>
  </head>
  <body>
    <a extra-attr>hola</a>
  </body>
</html>

What I need is:

  1. The attribute value present: <a extra-attr="value"></a> should be valid
  2. The attribute value not present: <a extra-attr></a> valid as well
Était-ce utile?

La solution

As said here:

A bareword attribute is a violation of the XML spec. The XHTML spec says that the best way around such cases where HTML has a bareword attribute (selected, checked, multiple, etc.) is to use selected="selected", checked="checked", and so on. An SGML HTML parser (web browser) will ignore the value it's given, and an XML XHTML parser (good web browser) will acknowledge the value, and ignore it. A file with selected="selected" is valid XHTML, according to the W3C's validation program.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top