Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

anchor tag inside ul before li

Tags:

html

I am adding an anchor tag inside ul and inside anchor tag I am adding li. But when I tested this on html validator it gives me error. Is there a proper way to achieve this?

<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<ul>
<a href="#"><li>Click one</li></a>
<a href="#"><li>Click one</li></a>
<a href="#"><li>Click one</li></a>
</ul>
</body>
</html>
like image 317
Om3ga Avatar asked Jul 11 '12 10:07

Om3ga


1 Answers

Convert it to these:

<ul>
    <li><a href="#">Click one</a></li>
    <li><a href="#">Click one</a></li>
    <li><a href="#">Click one</a></li>
</ul>

Because li should always have a parent of ul, that is the cause of your error. But I think you wanted your whole li to be clickable so this CSS style will fix it.

ul li a { display:block; }

That will display it.

like image 71
Jeffrey Monte Avatar answered Nov 16 '22 02:11

Jeffrey Monte