Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    123
    Thanks
    20
    Thanked 1 Time in 1 Post

    Making the LI a link

    Hi,
    Is it possible to make the Li a link, instead of just having a link inside?
    Code:
    <a href="#"><li>Link</li></a>
    instead of
    Code:
    <li><a href="#">Link</a></li>
    How could I do this?

    Thanks

  • #2
    Regular Coder maxvee8's Avatar
    Join Date
    Feb 2008
    Location
    UK
    Posts
    185
    Thanks
    19
    Thanked 18 Times in 18 Posts
    in my opinion no ... same amount of code ... what would be the gaim from doing that ?
    "I have not failed, I've found 10,000 ways that don't work" Thomas Edison

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,636
    Thanks
    6
    Thanked 1,003 Times in 976 Posts
    No, it’s not possible to do that. An anchor element is an inline element while a list item is a block level element. Blocks can contain inline elements but not vice versa. However, you can style elements using CSS to make the appear as block or inline (among other options). What you wanna do is make the link inside the list item display: block;.

    You will probably run into problems with IE, though (too much space between list items), which can be fixed by applying layout to the list items.

  • #4
    Regular Coder
    Join Date
    Jan 2007
    Posts
    123
    Thanks
    20
    Thanked 1 Time in 1 Post
    Quote Originally Posted by VIPStephan View Post
    No, it’s not possible to do that. An anchor element is an inline element while a list item is a block level element. Blocks can contain inline elements but not vice versa. However, you can style elements using CSS to make the appear as block or inline (among other options). What you wanna do is make the link inside the list item display: block;.

    You will probably run into problems with IE, though (too much space between list items), which can be fixed by applying layout to the list items.
    So what exactly should I do? (Don't quite understand)

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,636
    Thanks
    6
    Thanked 1,003 Times in 976 Posts
    What’s there to not understand?
    1. Make the link inside the list item display as block by applying display: block; to it in your stylesheet.
    2. Apply layout to the list items (i.e. by applying height: 1%;)

  • Users who have thanked VIPStephan for this post:

    cheechm (05-07-2008)

  • #6
    New to the CF scene
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you use the following code it will achieve the result you are looking for.

    <li onclick="document.location.href='thelink.html'"><p>Other Stuff</p></li>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •