tags:

views:

72

answers:

2

Hi there, I've never come across this problem before and its quite annoying me. I have a list which when hovered over, a box appears around it. I have a list set out like the following

<div id="sidebar">
    <h2>Our Services</h2>

    <ul>
        <a href="furniture.php"><li>Furniture</li></a>
        <a href="kitchens.php"><li>Kitchens</li></a>
        <a href="bedrooms.php"><li>Bedrooms</li></a>
        <a href="flooring.php"><li>Flooring</li></a>
        <a href="externaljoinery.php"><li>External Joinery</li></a>
        <a href="commercialwork.php"><li>Commercial Work</li></a>
        <a href="staircases.php"><li>Staircases</li></a>
        <a href="tiling.php"><li>Tiling</li></a>
    </ul>
</div>

But for some reason firefox doesnt render the whole list item as a link, only the text. It works across other browsers (even IE) but not firefox.

+11  A: 

Change

<a href="furniture.php"><li>Furniture</li></a>

To

<li><a href="furniture.php">Furniture</a></li>

Inside a UL you are supposed to have LI elements, not anything else. However, inside the LI you can have other tags such as A

Update

You can set the style of A to display:block as mwgriffith suggested on comments.

or to make the whole line a link you can also assign a click event on the LI, here is an example using jQuery

BrunoLM
Is `<ul><a href="furniture.php"><li>Furniture</li></a></ul>` valid HTML anyway?
Bruno
No, you can't have any tags but `LI` directly under `UL`
BrunoLM
That is unfortunatly not doing what I want, if I put the <a> inside the <li> then only the text is a link, instead of the whole list which all browsers except firefox is doing.For example, I have the list item as 50px wide and 30px high, and all browsers are rendering the list item as a link like I want, except firefox which renders only the text as a link.
Keiron Lowe
You might be able to use display:block; on the either the li or a href tags and it might work the way you want it too.
mwgriffith
A tip: validate. http://validator.w3.org/ tells you exactly what the problems are.
Ain
A: 

I figured it out, instead of having the <li> display the background I used display:block on the <a> tags and uses the a:hover to create the background.

Keiron Lowe