Is div inside list allowed?

Kenan picture Kenan · Dec 16, 2009 · Viewed 160.4k times · Source

I know that DIV inside LI isn't allowed, but I've seen it lately on many "big" websites like Smashing Magazine, Web Designer Wall... etc.

I tried to validate sites, and they have errors, but nothing about DIV in LI?!

So can I use it inside LI, and I need it to be valid?

Answer

Darin Dimitrov picture Darin Dimitrov · Dec 16, 2009

Yes it is valid according to xhtml1-strict.dtd. The following XHTML passes the validation:

<?xml version="1.0"?>
<!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" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test</title>
</head>
<body>
<ul>
  <li><div>test</div></li>
</ul>
</body>
</html>