Setting links to not do something

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KeredDrahcir
    Contributor
    • Nov 2009
    • 426

    #1

    Setting links to not do something

    I have some list items and in some cases I want to display a link inside the list
    Code:
    <ul class="list_name">
      <li><a href=""></a></li>
      <li><a href=""></a></li>
      <li></li>
    </ul>
    On the list items I'm using
    Code:
    .list_name li{
      padding-top: 7px;
    }
    to set padding. To style the linked ones I'm using
    Code:
    .last_name li a{
    }
    Is there anyway to set it not to have the padding on the links?
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    No. This can't be done in CSS.

    Comment

    • KeredDrahcir
      Contributor
      • Nov 2009
      • 426

      #3
      Do I have any options?

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        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.

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          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.

          Comment

          • KeredDrahcir
            Contributor
            • Nov 2009
            • 426

            #6
            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.

            Comment

            • drhowarddrfine
              Recognized Expert Expert
              • Sep 2006
              • 7434

              #7
              I didn't know that was an option. You can look into the 'not:' selector but it only works in modern browsers and IE9.

              Comment

              Working...