Skip to content

Week 7 PHP Passed HTML validation but throws a warning

September 30, 2012

Is this something to worry about? The warning seems to relate to my header includes code, but none of my other pages give me the same warning. Can’t figure it out…
http://senna.sjsu.edu/dchristiansen/netzloffj/assignments/wk7_netzloff.php

Advertisements
2 Comments leave one →
  1. blazekj permalink
    September 30, 2012 5:28 pm

    I got the same warning, so I’ll take a stab here. Someone else can correct me if I’m wrong. The validator reads this page as HTML 4.01 rather than XHTML, as it reads every other page. My guess is that this is because PHP is an HTML compliant script that doesn’t quite jive with XHTML. So the PHP on this page causes the page to be validated according to the HTML 4.01 standard rather than XHTML. While our headers are good XHTML and aren’t even bad HTML, they are confusing to the validator because it can’t tell which standard it’s supposed to be using to validate. So it’s giving us a warning that something looks fishy here and might be a mistake even though it doesn’t actually see invalid code.
    In short, my guess is this warning stems from PHP not playing completely nice with XHTML. Does that make sense, or am I way off?

  2. derek permalink*
    October 2, 2012 3:03 pm

    Actually the warning in this case is quite specific: no forward slash is necessary on empty elements like the img element in your banner. If you read the DOCTYPE declaration in the file you will see that it declares HTML 4.01 and not XHTML transitional. The reason we use this is the senna stack breaks if you try to serve a PHP file with an XML declaration which is required to make valid XHTML.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: