0

Although this page seems to load file, I get an error from NU HTML checker. Not sure how to clear the error, because it seems everything in the body would of course be a child of the XHTML body element.

<?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" xml:lang="en" lang="en">
   <head>
      <title>How About Them Apples?</title>
      <meta charset="utf-8" />
      <link href="apples.css" rel="stylesheet" type="text/css" />
   </head>
   <body>  
       <apples xmlns:apls="https://www.dole.com/en/products/apples">
          <apls:apple>
             <apls:name>Red Delicious</apls:name>
             <apls:color>Red</apls:color>
          </apls:apple>
          <apls:apple>
             <apls:name>Golden Delicious</apls:name>
             <apls:color>Yellow</apls:color>
          </apls:apple>
       </apples>
   </body>
</html>
John Heyer
  • 711
  • 1
  • 6
  • 18
  • That's not XHTML. That's XHTML + something else. The something else bit isn't going to pass a validator that's expecting just XHTML. – Alohci Dec 06 '20 at 00:03
  • It's XML embedded in HTML, which is a valid part of XHTML according to this: https://www.cs.unc.edu/Courses/comp416-f10/lectures/lecture03/lecture03.html – John Heyer Dec 06 '20 at 18:38
  • I'm not sure it actually says that, but if it does, it's incorrect. It's perfectly acceptable XML, and you are at liberty within the rules of *XML* to mix XHTML with elements from other namespaces, but if you do, it ceases to be valid XHTML. No version of XHTML has ever allowed elements from arbitrary namespaces into its content model. If you want to do so, you need to decide your own rules about what is and is not valid rather than rely on XHTML's rules. – Alohci Dec 06 '20 at 21:22
  • Well, it renders fine in Chrome, FireFox, and Edge. So I'm not sure what to tell you – John Heyer Dec 06 '20 at 21:52
  • Sure. Browsers handle it fine. Furthermore, the HTML5 specification defines exactly how browsers should handle it. It's also true that browsers can handle XML documents without any HTML in them at all. What is valid, and how browsers handle HTML and XML documents are two independent things. The most that can be said is the how browsers handle documents *helps* establish what is considered valid, but never vice-versa. – Alohci Dec 06 '20 at 21:59

0 Answers0