By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Setting links to not do something

KeredDrahcir
100+
P: 426
I have some list items and in some cases I want to display a link inside the list
Expand|Select|Wrap|Line Numbers
  1. <ul class="list_name">
  2.   <li><a href=""></a></li>
  3.   <li><a href=""></a></li>
  4.   <li></li>
  5. </ul>
On the list items I'm using
Expand|Select|Wrap|Line Numbers
  1. .list_name li{
  2.   padding-top: 7px;
  3. }
to set padding. To style the linked ones I'm using
Expand|Select|Wrap|Line Numbers
  1. .last_name li a{
  2. }
Is there anyway to set it not to have the padding on the links?
Jan 11 '12 #1
Share this Question
Share on Google+
6 Replies


drhowarddrfine
Expert 5K+
P: 7,435
No. This can't be done in CSS.
Jan 11 '12 #2

KeredDrahcir
100+
P: 426
Do I have any options?
Jan 11 '12 #3

drhowarddrfine
Expert 5K+
P: 7,435
I was going to suggest adding the padding or margin to the anchor. If the anchor is not present, then nothing will happen.

Of course, there's always javascript.
Jan 11 '12 #4

Rabbit
Expert Mod 10K+
P: 12,430
I suppose you could give each of the list items a class depending on whether or not it had an anchor and do it that way.
Jan 11 '12 #5

KeredDrahcir
100+
P: 426
Thanks Rabbit. I was thinking of doing that.

Your suggestion is what I did drhowarddrfine but I don't want the padding on the links. I want it on the list items that don't have links.
Jan 12 '12 #6

drhowarddrfine
Expert 5K+
P: 7,435
I didn't know that was an option. You can look into the 'not:' selector but it only works in modern browsers and IE9.
Jan 12 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.