...

View Full Version : Making the LI a link



cheechm
05-07-2008, 07:40 PM
Hi,
Is it possible to make the Li a link, instead of just having a link inside?

<a href="#"><li>Link</li></a>
instead of

<li><a href="#">Link</a></li>

How could I do this?

Thanks

maxvee8
05-07-2008, 08:05 PM
in my opinion no ... same amount of code ... what would be the gaim from doing that ?

VIPStephan
05-07-2008, 08:25 PM
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 (http://satzansatz.de/cssd/onhavinglayout.html) to the list items.

cheechm
05-07-2008, 08:49 PM
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 (http://satzansatz.de/cssd/onhavinglayout.html) to the list items.
So what exactly should I do? (Don't quite understand)

VIPStephan
05-07-2008, 10:45 PM
What’s there to not understand?

Make the link inside the list item display as block by applying display: block; to it in your stylesheet.
Apply layout to the list items (i.e. by applying height: 1%;)

codingdoggie
05-28-2010, 05:24 AM
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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum