Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-07-2008, 06:40 PM   PM User | #1
cheechm
Regular Coder

 
Join Date: Jan 2007
Posts: 123
Thanks: 20
Thanked 1 Time in 1 Post
cheechm is an unknown quantity at this point
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
cheechm is offline   Reply With Quote
Old 05-07-2008, 07:05 PM   PM User | #2
maxvee8
Regular Coder

 
maxvee8's Avatar
 
Join Date: Feb 2008
Location: UK
Posts: 185
Thanks: 19
Thanked 18 Times in 18 Posts
maxvee8 is an unknown quantity at this point
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
maxvee8 is offline   Reply With Quote
Old 05-07-2008, 07:25 PM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,600
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 05-07-2008, 07:49 PM   PM User | #4
cheechm
Regular Coder

 
Join Date: Jan 2007
Posts: 123
Thanks: 20
Thanked 1 Time in 1 Post
cheechm is an unknown quantity at this point
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)
cheechm is offline   Reply With Quote
Old 05-07-2008, 09:45 PM   PM User | #5
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,600
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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%;)
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
cheechm (05-07-2008)
Old 05-28-2010, 04:24 AM   PM User | #6
codingdoggie
New to the CF scene

 
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
codingdoggie is an unknown quantity at this point
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>
codingdoggie is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:27 AM.


Advertisement
Log in to turn off these ads.