0

This sample code won't pass w3c validator.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:foo="http://foo.com/fooxml">
<head>
    <title>Foo</title>
</head>
<body>
    <foo:TabControl>

    </foo:TabControl>
</body>
</html>

What am I missing? What do I need to do to make namespaces to work and pass validation?

Tower
  • 98,741
  • 129
  • 357
  • 507

1 Answers1

2

Your DTD (http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd) is "XHTML 1.0 Strict" not "XHTML 1.0 Strict + Foo".

If you want to validate you will need to find or create a DTD that includes all the elements and attributes you are using, and change the Doctype to point at that.

The W3C's list of recommended Doctypes includes a number of multiple namespace documents (such as XHTML + MathML + SVG) that you could use as examples for creating your own.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Can I create an XHTML document that is based on the existing HTML DTD (html, head, body, div, ul, etc) and then just add this namespace and use it `foo:TabControl`? I wouldn't want to recreate the entire HTML along with all its elements. Can you make hybrid doctypes? – Tower Apr 09 '12 at 15:34
  • XHTML is expressed in modules to make creating mixed namespace documents easier. See the DTDs I suggested as examples in my answer. – Quentin Apr 09 '12 at 15:35
  • Ah I see. So I just create my own DTD with the elements of my choice, such as `TabControl`, then I create a joined DTD called XHTML+Foo? – Tower Apr 09 '12 at 15:38
  • Will a browser render the normal HTML tags? – Melab Apr 12 '19 at 04:08