0

I have a css sprite navigation bar where the li's are wrapped in a href tags for linking...

<div id="header"> <ul> <a href="/"><li id="supplements-link"></li></a> <a href="/tutorials/"><li id="tutorials-link"></li></a> <a href="/blog/"><li id="blog-link"></li></a> </ul> </div> 

It works fine for me in Safari, Chrome, Opera & IE - but the links aren't active in Firefox, and when I look at the code in Firebug, Firefox renders the a href and li tags as separate lines:

<div id="header"> <ul> <li id="supplements-link"></li> <a href="/"></a> <li id="tutorials-link"></li> <a href="/tutorials/"></a> <li id="blog-link"></li> <a href="/blog/"></a> </ul> </div> 

Any tips? Thanks!

0

5 Answers 5

8

li elements are the only elements that can be children of ol or ul. Your HTML is invalid at the moment.

Please wrap the lis around the as.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep - the LIs are the containers, the As are the content.
0

You'll want to style up the a inside the li making it's width and height 100%, here's some other suggestions:

http://doctype.com/make-li-clickable-target-url

Comments

0

Why not just put the anchor tags inside the LI elements? That's how it's usually done.

Comments

0

<ul> doesn't support <a> as a child, your html is not properly formatted, try this instead:

<div id="header"> <ul> <li id="supplements-link"><a href="/"></a></li> <li id="tutorials-link"><a href="/tutorials/"></a></li> <li id="blog-link"><a href="/blog/"></a></li> </ul> </div> 

Comments

0

You need to put a's inside li's, and then display: block; in your CSS, this will make the whole li a link instead of just the text, which I think is what you're probably trying to achieve?

That way you then add padding etc to your <a> tag to make the link blocks bigger. This will solve the FF issue:

CSS:

#header ul li a { display: block; padding: 10px; } 

HTML:

<div id="header"> <ul> <li id="supplements-link"><a href="/">Supps link</a></li> <li id="tutorials-link"><a href="/tutorials/">Tuts link</a></li> <li id="blog-link"><a href="/blog/">Blog link</a></li> </ul> </div> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.