Reputation: 693
Today I came across a new problem.
As most of you probably already know, the a:target="_blank" is not validate XHTML Strict. But today I wanted to add icons for iPod, iPhone and iPads to the website. The piece of code needed for this is:
<link rel="apple-touch-icon" href="logo_144.png" sizes="144x144" />
As you probally guessed the attribute sizes isn't valid either. The biggest problem is XHTML1.1 is a must. So I can't go to HTML5 or transitional. I found out I could use a custom DTD, which isn't preferred. I also found out it is possible to add a few custom DTD lines to expand the original. The code was:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
<!ATTLIST link sizes CDATA #IMPLIED >
]>
This, which obviously did not do the job, printed ']>' right into the page, given me more errors such as no charset. I tried to change 'PUBLIC' into 'SYSTEM' without any luck.
Is there a right way to do this? Thanks in advance!
Upvotes: 1
Views: 1759
Reputation: 10324
If you would like to suppress the attribute sizes validation error inorder to validate the rest of the document, you could insert <!ATTLIST link sizes CDATA #IMPLIED>
on the fly while validating. Here's an xmllint
example:
sed '/<!DOCTYPE/ {
s/\([^>]*\)/\1 [<!ATTLIST link sizes CDATA #IMPLIED>]/
}
' input.html | \
xmllint --noout --valid - 2>/dev/null || \
echo "Not valid: input.html"
Upvotes: 0
Reputation: 1
You can always use type instead of sizes.
<link rel="apple-touch-icon" type="72x72" href="/theme/mobile/72x72.png" />
Upvotes: 0
Reputation: 3882
There are two correct ways to go about doing this, depending on your preference.
Your above example looks correct, I'm not sure which browser you were trying that was printing the ]>
- it could perhaps be the extra space at the end of the ATTLIST:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
<!ATTLIST link sizes CDATA #IMPLIED>
]>
The other - probably slightly easier - option is to opt for the XML serialization of HTML5 (often called XHTML5); as the size attribute has been added in HTML5 it would seem to make most sense. Using this you can exclude the doctype altogether as the HTML5 validator opts for RELAX NG Schema for validation purposes instead of DTDs, but it is generally recommended to leave the doctype in for general portability and compatibility with IE8 and below using a HTML5 Polyglot
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
Upvotes: 0
Reputation: 944171
Is there a right way to do this?
No.
You can either use XHTML 1.1 (there is no such thing as XHTML 1.1 Strict) or you can use something with a sizes
attribute on the link
element.
If you use a custom DTD, then you aren't using XHTML 1.1 any more (you are using your custom language).
Upvotes: 1