I am just validating my webpage and working through the errors. the scenario I have is that I have the structure where I import a header file, through <?php include ('header.php') ?> and also with my navigation file. Now in terms of seeing it in the browser this works, but when I validate with XHMTL1.1 strict it comes up with the error.
So I have an index.php which imports both the header.php and navigation.php – now as I am writing this I am realizing that the navigation.php does not get the css file imported into it, but does the validator not just read the html? so there it should pick it up and see that it gets the information?
Please let me know if I am on the right track with this, otherwise it seems that you sacrifice validation for a structured website??
Cheers Jeff PS Happy New Year:-)
EDIT CODE:
URI: http://thepalmsmarket.co.nz/index.php a
276 9 there is no attribute “id” a
276 24 there is no attribute “class” a
276 38 element “nav” undefined
I these are the last errors and they are related to this code:
index.php:
<?php include_once ("01includes/header.php"); ?>
</head><!--hmtl tag closes in the footer-->
<body class="no-js"><!--The script here is to disable the class put into the body tag if javascript is enabled.-->
<?php include_once ("01includes/navigation.php"); ?>
navigation.php:
<nav id="topNav" class="centeredmenu">
<ul>
<?php
$subject_set = mysql_query("SELECT * FROM webMenu", $dbconnect);
if (!$subject_set) {
die("Database query failed: " . mysql_error());
}
while ($subject = mysql_fetch_array($subject_set)) {
echo "<li class=\"{$subject["class"]}\"><a href=\" {$subject["link"]}\" onclick=\"{$subject["javascript"]}\" title=\"{$subject["title"]}\">{$subject["menuItem"]}</a></li>"; }
?>
</ul>
The css is declared in desktop.css which is imported into header.php, but not into navigation.php as that would be a double up – hope that makes sense:-)
Good news: nothing to do with PHP. You appear to be using the
navtag, which is new in HTML5, while validating against the XHTML 1.1 Strict. If you switch to an HTML5 declaration, so that you can usenavin a nice, valid, semantic way, then you’ll have to chase down a few other validation errors (mostly related to the meta tags, and then use of a deprecatedborderattribute further on in your code — the validation errors should be self-explanatory). If you want to keep on with XHTML, then drop the use ofnavto be valid.