Canvas Validation Xhtml
Solution 1:
As was said in the comments, using the doctype for HTML5 (<!DOCTYPE html>
) is the sane choice.
However, it might be you're stuck with XHTML 1 for whatever reason. One such reason could be, because XHTML 1 has a real DTD, it supports the use of entity references like
and þ
. (XHTML5 doesn't have such luxury!)
If so, you might have noticed that the browsers already support newer elements like canvas
, so you don't really have to do anything to make it work. All you need to do is satisfy the validator!
So here's the trick. All you need to do is add the newer elements to the doctype declaration, as if they were part of the DTD.
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE htmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
[
<!ELEMENT canvasEMPTY><!ATTLIST canvasidID#IMPLIEDclassCDATA#IMPLIEDstyleCDATA#IMPLIEDtitleCDATA#IMPLIEDlangCDATA#IMPLIEDxml:lang CDATA#IMPLIEDdir (ltr|rtl) #IMPLIEDonclickCDATA#IMPLIEDondblclickCDATA#IMPLIEDonmousedownCDATA#IMPLIEDonmouseupCDATA#IMPLIEDonmouseoverCDATA#IMPLIEDonmousemoveCDATA#IMPLIEDonmouseoutCDATA#IMPLIEDonkeypressCDATA#IMPLIEDonkeydownCDATA#IMPLIEDonkeyupCDATA#IMPLIEDheightCDATA#IMPLIEDwidthCDATA#IMPLIED
><!ENTITY % InlSpecial.class
" | audio | canvas | embed | iframe | img | math | object | svg | video">
]
><htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en-us"><head><title>Element test</title></head><body><div><canvasid="canvas"width="500"height="250"style="background-color:#303030;"></canvas></div></body></html>
By the way, if you think this is a bit much, remember that you only need to do this to satisfy the validator, so you can remove all attributes from the ATTLIST except the ones you're actually using (in your example, id
, width
, height
and style
).
Post a Comment for "Canvas Validation Xhtml"