[英]w3 validator gives my navigation errors
I've been doing some researching and discovered this nice website http://validator.w3.org/ 我一直在做一些研究,发现了这个不错的网站http://validator.w3.org/
After running a test i see that my navigation get loads of error. 运行测试后,我发现导航出现很多错误。
The error i get is the ul in the coding. 我得到的错误是编码中的ul。 I don't close it off because i give it it styling if a condition is met else close it.
我不会关闭它,因为如果满足条件,我会给它造型,否则将其关闭。
But this is not a valid solution according to w3 which gives me some errors. 但这不是w3的有效解决方案,它给了我一些错误。
Can you help me find a fix for my navigation so it gets valid? 您能帮我找到一个导航修复程序,使其生效吗?
With thanks Jim 谢谢吉姆
<ul id="nav-container">
<?php
$select_category = mysql_query("SELECT * FROM menu WHERE hidden = 0 ORDER BY menu ASC");
while ($ln = mysql_fetch_array($select_category)) {
$idcat = $ln['nmr'];
$catname = $ln['menu'];
$catsname = str_replace(' ', '-', $ln['menu']);
echo '<li>';
if($catname == "carparts") {
echo '<a href="http://www.mywebsite.com/carparts.php" title="'.$catname.'"><span><strong>'.$catname.'</strong></span></a>';
} else {
echo '<a href="http://www.mywebsite.com/'.$idcat.'/'.$catsname.'/" title="'.$catname.'"><span><strong>'.$catname.'</strong></span></a>';
}
This gives me the errors: (fixed) 这给了我错误:(已修复)
echo '<ul';
if(isset($_GET['cats'])) {
if ($_GET['cats'] == $idcat) {
echo ' style="display:block;">';
} else {
echo '>';
}
The fix: also deleted the closing bracket at the end. 解决方法:还删除了结尾处的右括号。
echo '<ul';
if(isset($_GET['cats']) && $_GET['cats'] == $idcat){
echo ' style="display:block;">';
} else {
echo '>';
}
/fix finish /修复完成
//Error finish //错误完成
$select_sub = mysql_query("SELECT * FROM submenu WHERE nmrmenu = '$idcat' AND hidden = 0");
while ($lsub = mysql_fetch_array($select_sub)) {
$subname = $lsub['submenu'];
$subsname = str_replace(' ', '-', $lsub['submenu']);
$pil = '»';
$brnr = $lsub['nmr'];
if(isset($_GET['cat'])) {
if ($_GET['cat'] == $brnr) {
$subname = '<u>'.$lsub['submenu'].'</u>';
} else {
$subname = $lsub['submenu'];
}
}
echo '<li><a href="http://www.mywebsite.com/'.$lsub['nmr'].'/'.$subsname.'/"><span><strong> '.$subname.' </strong></span></a></li>';
}
echo '</ul>';
echo '</li>'; // to this location
}
echo '</li>'; //relocated this up one line
} **//Deleted this one!**
?>
</ul>
Update 更新
The output gets like this which is horrible: (fixed) 输出变得像这样,这太可怕了:(固定)
<ul</li><li><a href="http://www.mywebsite.com/x/name/" title="name"><span><strong>name</strong></span></a>
<ul</li><li><a href="http://www.mywebsite.com/x/name/" title="name"><span><strong>name</strong></span></a><ul</li>
New: now the ul problem is gone, but it's complaining about the li's. 新增内容:现在ul问题已经解决了,但它在抱怨li的问题。 Any clue why?
有什么线索吗?
Error: document type does not allow element "li" here; 错误:此处的文档类型不允许元素“ li”; missing one of "ul", "ol", "menu", "dir" start-tag
缺少“ ul”,“ ol”,“ menu”,“ dir”开始标签之一
<ul id="nav-container">
<li>
<a href="http://www.mywebsite.com/x/name/" title="name"><span><strong>name</strong></span></a>
<ul>
<li>
<a href="http://www.mywebsite.com/x/name/"><span><strong> name </strong></span></a>
</li>
</ul>
</li>
</ul>
/update /更新
You have </ul>
and then immediately follow it with a <li>
. 您拥有
</ul>
,然后立即使用<li>
跟随它。 You can't have a list item outside of a list. 您不能将列表项放在列表之外。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.