Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 05-06-2014, 06:02 AM
JSmith250 JSmith250 is offline
Contributing Member
 
Join Date: 03-31-14
Posts: 79
iTrader: 0 / 0%
W3 Validator errors

Hi, I'm a junior coder so maybe my questions it will look like a stupid question but I don't get it where is the problem on my site.

http://validator.w3.org/check?uri=ht...oaca-mario.ro/

! The last 3 errors are which they interested me:

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. and for the last error the div pagination have a closed tag so I don't get it

Also maybe this code may help for these errors

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> <? } pagination($nrPagini, $pg, '?pg=%pg'); } else { echo 'Database empty.'; } ?> </ul> </div>
Where is the problem in my code, how can I fix it? Thanks.

Last edited by JSmith250; 05-06-2014 at 06:06 AM.
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 05-06-2014, 06:27 AM
Katt's Avatar
Katt Katt is offline
Moderator
 
Join Date: 12-14-13
Location: Texas
Posts: 1,563
iTrader: 0 / 0%
you have a div as a child of the ul, which is not allowed. Move the div outside the ul, or put it in an li and it will validate.
 
Reply With Quote
  #3  
Old 05-06-2014, 06:37 AM
JSmith250 JSmith250 is offline
Contributing Member
 
Join Date: 03-31-14
Posts: 79
iTrader: 0 / 0%
I tried and still don't works, it give me more errors.

Quote:
Originally Posted by Katt View Post
you have a div as a child of the ul, which is not allowed. Move the div outside the ul, or put it in an li and it will validate.
 
Reply With Quote
  #4  
Old 05-06-2014, 06:55 AM
Katt's Avatar
Katt Katt is offline
Moderator
 
Join Date: 12-14-13
Location: Texas
Posts: 1,563
iTrader: 0 / 0%
you still have a div as a child of a ul - I just revalidated and had it show source - this is the problem :

Code:
<div class="pagination" id="pagination"> <span class="disabled">Inapoi</span> <span class="current">1</span> <a href="?pg=2" title=" Pag 2">2</a> <a href="?pg=2" title="Inainte" class="next">Inainte</a> </div> </ul>
You need to move that div outside the ul, or put it in an li.
 
Reply With Quote
  #5  
Old 05-06-2014, 07:22 AM
JSmith250 JSmith250 is offline
Contributing Member
 
Join Date: 03-31-14
Posts: 79
iTrader: 0 / 0%
Yes I put how was before that why is the same code. I will figure it out what you say and I will try to fix it.

Quote:
Originally Posted by Katt View Post
you still have a div as a child of a ul - I just revalidated and had it show source - this is the problem :

Code:
<div class="pagination" id="pagination"> <span class="disabled">Inapoi</span> <span class="current">1</span> <a href="?pg=2" title=" Pag 2">2</a> <a href="?pg=2" title="Inainte" class="next">Inainte</a> </div> </ul>
You need to move that div outside the ul, or put it in an li.
 
Reply With Quote
  #6  
Old 05-06-2014, 07:51 AM
JSmith250 JSmith250 is offline
Contributing Member
 
Join Date: 03-31-14
Posts: 79
iTrader: 0 / 0%
I put the pagination div outside de ul tag and close the while statment like that

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>
See the bold line, there i close the while statment because if i don't close there he still continue to echo many ul and li tags not properly, that's why i say it give me more errors but now I fix it. Thanks

Quote:
Originally Posted by JSmith250 View Post
Yes I put how was before that why is the same code. I will figure it out what you say and I will try to fix it.
 
Reply With Quote
  #7  
Old 05-06-2014, 02:16 PM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Administrator
 
Join Date: 10-29-07
Location: Canada
Posts: 26,656
iTrader: 5 / 100%
Try changing your list item to:
Code:
<li> <span 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> </span> </li>
I changed your div to span.

But a better solution is to move all that styling to the external stylesheet.
 
Reply With Quote
  #8  
Old 05-07-2014, 11:15 AM
JSmith250 JSmith250 is offline
Contributing Member
 
Join Date: 03-31-14
Posts: 79
iTrader: 0 / 0%
I will fix it, thanks but I searching on the internet and inside ul li tags the DIV tag you can use it, it is valid but how you say to change with span maybe it is better.

Quote:
Originally Posted by HTMLBasicTutor View Post
Try changing your list item to:
Code:
<li> <span 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> </span> </li>
I changed your div to span.

But a better solution is to move all that styling to the external stylesheet.
 
Reply With Quote
  #9  
Old 05-08-2014, 11:11 PM
williamforrest williamforrest is offline
Contributing Member
 
Join Date: 12-01-13
Posts: 98
iTrader: 0 / 0%
div is not allowed inside an <li> tag..
 
Reply With Quote
  #10  
Old 05-09-2014, 09:53 AM
J. H. Rasmussen J. H. Rasmussen is offline
Super Moderator
 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 5,985
iTrader: 1 / 100%
Quote:
Originally Posted by williamforrest View Post
div is not allowed inside an <li> tag..
Got a link to a reliable source to back that up?
 
Reply With Quote
  #11  
Old 05-09-2014, 12:21 PM
JSmith250 JSmith250 is offline
Contributing Member
 
Join Date: 03-31-14
Posts: 79
iTrader: 0 / 0%
I'm 99% sure div are allowed in a li tag, I don't find the link but the HTML site or something says is valid to have a div in a li tag.
 
Reply With Quote
  #12  
Old 05-09-2014, 03:11 PM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Administrator
 
Join Date: 10-29-07
Location: Canada
Posts: 26,656
iTrader: 5 / 100%
This validates for HTML5
Code:
<!DOCTYPE html> <html> <head> <title>Untitled Document</title> <meta charset="UTF-8"> <style type="text/css"> .redbg{background-color: red; } </style> </head> <body> <ul> <li>Some text <div class="redbg">Some text with red background </div> </li> </ul> </body> </html>
This validated in XHTML Strict:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <style type="text/css"> .redbg{background-color: red; } </style> </head> <body> <ul> <li>Some text <div class="redbg">Some text with red background </div> </li> </ul> </body> </html>
This validates in HTML 4.01 Strict:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <style type="text/css"> .redbg{background-color: red; } </style> </head> <body> <ul> <li>Some text <div class="redbg">Some text with red background </div> </li> </ul> </body> </html>
If you can't get yours to validate then there probably something above this area that has confused the validator or your rendered coding is incorrect.

Still, it would be better to do all formatting in the external stylesheet instead of inline like you had it originally.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Do you know about W3C validator? vajra Google Forum 9 09-10-2012 10:51 AM
Web 2.0 Validator Ferre Web Design Lobby 4 04-08-2007 11:21 PM
HTML Validator Converter SN3 Coding Forum 4 01-17-2004 05:17 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 10:58 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC