View Full Version : Using <li> within a floating DIV? Works, but site no longer validates

01-20-2005, 10:38 PM
I have a floating DIV on my site that uses PHP to select news articles out of an SQL database.

I use echo to print the news articles:

echo "<ul>";
echo "<li>" . date('F j, Y', strtotime($date)) . " - " . $news . "</li>";
echo "</ul>"

Which outputs:
<li>Month Date, Year - Article</li>
<li>Month Date, Year - Article</li>

But now the page no longer validates as XHTML:

Line 40, column 10: document type does not allow element "ul" here; missing one of "object", "ins", "del", "map", "button" start-tag

<ul><li>January 20, 2005 - This is a test</li><li>January 16, 2004 - Welc

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

01-20-2005, 11:01 PM
Nevermind, I got it.

I didn't see that I had this code within a <p> </p>