简体   繁体   English

我的网站的W3验证程序错误

[英]W3 Validator errors for my website

Maybe my question will look a little weird but I spend 1 day to figure it out where is the problem and I don't get it 也许我的问题看起来有点怪异,但我花了1天的时间弄清楚问题出在哪里,但我不明白

Here's the link of W3 这是W3的链接

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

Here is the site: http://www.joaca-mario.ro/ 这是网站: http : //www.joaca-mario.ro/

The last 3 errors are which they interested me: 最后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

I don't know where is the problem but to me when I check the source code the ul and li tags looks fine. 我不知道问题出在哪里,但是对我来说,当我检查源代码时,ul和li标签看起来不错。 and for the last error the div pagination have a closed tag so I don't get it 对于最后一个错误,div分页有一个关闭的标签,所以我不明白

Also maybe this code may help for my errors: 另外,也许这段代码可以帮助解决我的错误:

<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>

SOLVED: 解决了:

I hope it is correct my new code: 我希望我的新代码正确:

<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>

What I did? 我做了什么? So I put the pagination line after the ul tag was close and I close the while statment(see <? } { ?> line) because if I don't close there it still continue to echo(in source code) many ul and li tags not properly. 因此,我在ul标签关闭后放置了分页线,并关闭了while语句(请参见<? } { ?>行),因为如果我不关闭那里,它仍然继续回显(在源代码中)许多ul和li标签不正确。 I hope what I change is correct. 我希望我所做的更改是正确的。 Now the w3 validator say everything is ok. 现在,w3验证程序说一切正常。

You have your <div id="pagination"> as a child of the <ul> at the end of the list. 您将<div id="pagination">作为<ul>的子<ul>位于列表的末尾。 Move it outside of the <ul> or put it inside of its own <li> and it should fix the three errors. 将其移至<ul>或置于其自身的<li> ,它应该可以解决这三个错误。

W3 page for <ul> : <ul> W3页面

Permitted contents Zero or more li elements 允许的内容零个或多个li元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM