The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Question re: advanced CSS selectors

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #22670

    I’m designing a page where all text links need to have a little icon next to them to help denote that they’re links. So my CSS (simplified) looks like this:

    a {
    background-image: url(‘link.jpg’);
    background-position: left center;
    background-repeat: no-repeat;
    padding-left: 10px;

    The padding-left bumps the text over so that it isn’t sitting on top of the link icon.

    The problem is that sometimes I have other icons that are contained in links (like, for example, a document icon denoting a download), but I don’t want the link.jpg icon next to it. In such a case, my HTML looks like this:


    Is there any type of CSS selector where I can say, "if an image is contained by a link, style that parent link like X?"

    I realize that I could just make a separate class that doesn’t have the background image and apply it to every link that contains an image, but it would be much cooler if this could be done automatically. Is it possible? Does anyone know? :lol:

Viewing 1 post (of 1 total)
  • The forum ‘CSS’ is closed to new topics and replies.