Links with LI inside

Asked

Viewed 1,284 times

1

I have this structure:

<ul>
<li><a></a></li>
<li><a></a></li>
</ul>

Okay, what happens is that sometimes I need to put the link <a> above the li and not inside, as it is in the structure. How do you do it? I’ve used it before window.location, but I was wondering if there’s any way to do it without using javascript.

  • 3

    Explain better "put the click above the read and not inside".

  • I edited, I didn’t realize the mistake.

  • The correct structure is the link inside the li... In which situation would need to put the li inside the link?

  • @Felipestoker do you want the link to be on top of the <li>?? type like this? http://jsfiddle.net/k30jqdrd/

1 answer

7


It’s not recommended, and it’s literally not right for you to put something like:

<a><li></li></a>

Thus, as defined in the HTML standards rules, by w3c, within the tag <ol> or <ul>, we can only contain tag <li>.

What I suspect you want to do, is that the block of <li> integer be 'clickable', so recommend to add is the property "display: block" in the tag css <a>.

  • 1

    With display:block it will take all the content inside the a which respectively is within the li?

  • @Felipestoker will do that. Besides being the correct way to write the tags, because if you do the <a> wrapped <li>, nothing guarantees that it will work in all browsers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.