gpt4 book ai didi

html - 我网站的 W3 验证器错误

转载 作者:太空宇宙 更新时间:2023-11-04 13:29:01 25 4
gpt4 key购买 nike

也许我的问题看起来有点奇怪,但我花了 1 天时间弄清楚问题出在哪里,但我不明白

这是W3的链接

http://validator.w3.org/check?uri=http://www.joaca-mario.ro/

这是网站:http://www.joaca-mario.ro/

最后 3 个错误是我感兴趣的:

Line 159, Column 40: document type does not allow element "div" here; assuming missing "li" start-tag
Line 165, Column 5: end tag for "li" omitted, but OMITTAG NO was specified
Line 159, Column 1: start tag was here

我不知道问题出在哪里,但对我来说,当我检查源代码时,ul 和 li 标签看起来不错。对于最后一个错误,div 分页有一个封闭的标签,所以我不明白

也许这段代码可能有助于解决我的错误:

<div class="list">
<h2>Lista de jocuri recomandate - <?php if(empty($_GET) || $_GET['pg'] ==1) { echo 'Pagina 1'; } else { echo 'Pagina ' .$_GET['pg']; } ?></h2>
<ul>
<? // PHP Query + Pagination: //
$sql = "SELECT * FROM `db` ORDER BY `id` DESC"; $listLinksCount = mysql_num_rows(mysql_query($sql)); if($listLinksCount > 0) { $listLinks = mysql_query($sql.$sqlLimit); $nrPagini = ceil($listLinksCount / $perpage); } if($listLinksCount > 0) { while($db = mysql_fetch_array($listLinks)) { ?>
<li><div style="background:url(images/post.png) no-repeat; height:166px; width:197px; "><a href="/<?=$db['weblink']?>"><img src="/files/<?=$db['img']?>" class="img" width="120" height="100" title="Joaca acum <?=$db['title']?>" alt="<?=$db['title']?>" /><span class="title"><?=$db['title']?></span></a></div></li>
<? } pagination($nrPagini, $pg, '?pg=%pg'); } else { echo 'Database empty.'; } ?>
</ul>
</div>

已解决:

希望是对的我的新代码:

<div class="list">
<h2>Lista de jocuri recomandate - <?php if(empty($_GET) || $_GET['pg'] ==1) { echo 'Pagina 1'; } else { echo 'Pagina ' .$_GET['pg']; } ?></h2>
<ul>
<? // PHP Query + Pagination: //
$sql = "SELECT * FROM `db` ORDER BY `id` DESC"; $listLinksCount = mysql_num_rows(mysql_query($sql)); if($listLinksCount > 0) { $listLinks = mysql_query($sql.$sqlLimit); $nrPagini = ceil($listLinksCount / $perpage); } if($listLinksCount > 0) { while($db = mysql_fetch_array($listLinks)) { ?>
<li><div style="background:url(images/post.png) no-repeat; height:166px; width:197px; "><a href="/<?=$db['weblink']?>"><img src="/files/<?=$db['img']?>" class="img" width="120" height="100" title="Joaca acum <?=$db['title']?>" alt="<?=$db['title']?>" /><span class="title"><?=$db['title']?></span></a></div></li>
**<? } { ?>**
</ul>
<? } pagination($nrPagini, $pg, '?pg=%pg'); } else { echo 'Database empty.'; } ?>
</div>
<div class="clear"></div>

我做了什么?所以我在 ul 标签关闭后放置了分页行,并关闭了 while 语句(参见 <? } { ?> 行),因为如果我不关闭它,它仍然会继续回显(在源代码中)许多 ul 和 li 标签不正确.我希望我改变的是正确的。现在 w3 验证器说一切正常。

最佳答案

你有你的 <div id="pagination">作为 <ul> 的 child 在列表的末尾。将它移到 <ul> 之外或者把它放在它自己的 <li> 里面它应该修复这三个错误。

W3 page for <ul> :

Permitted contents Zero or more li elements

关于html - 我网站的 W3 验证器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23496526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com