Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear the last <li> tag within a <ul>

Tags:

css

xhtml

I know this is pretty basic, but it is giving me hangups. I have a basic list:

<ul>
    <li><a href="#">Insert Link Here</a></li>
    <li><a href="#">Insert Link Here</a></li>
    <li><a href="#">Insert Link Here</a></li>
</ul>

What do I need to do to make sure the last <li> item gets cleared? I've tried adding style="clear:both" to the end with no avail. Also I've added a 'div' after the last <li> tag before the closing </ul> tag, that works, but I know it doesn't validate.

like image 395
Jon Harding Avatar asked Sep 24 '10 14:09

Jon Harding


1 Answers

If you want to have the background behind a block item which has only floated items inside, then:

ul {
  overflow: auto;
}
like image 188
KARASZI István Avatar answered Nov 03 '22 18:11

KARASZI István