treehouse : what would you like to learn today?
Web Design Web Development iOS Development

CSS Hierarchy Confusion

  • AHH! I keep thinking I'm understanding this but then I get stuck again. Sorry I'm going to have to describe the problem and not use proper terminology.

    Okay, so if I have an overarching style in wordpress, like ".entry img" that applies to any image within the "entry" class, but I want to make an exception for en entire page's images (or do them individually if need be), how can I override the broad styling to make an exception? What's the best way? I've got 5px padding right now and on one page I want it to be 1px.

    Sorry for such a basic one, and that I don't know the terminology well enough to search for a previous forum post.
  • you can do this by giving each page a body class. This way for your exception, you can do something like..

    body.contact .entryimg {
    float: right;
    }
  • Christopher, do you mean just putting
    CONTENT
    within the post? Or are you talking about some modification to the existing css structure of my premium theme?
  • Say for example the style in question is a border. You have it set up something like this:
    .entry img {
    border:1px solid #F00
    }
    Now, if on a specific page you dont want the images in .entry to have a border then what you would do is add a class or id to the body tag at the top of the page. For example, go from:
    <body>
    to:
    <body id="about">
    "about" could be whatever you want. Name it something relative to the page. Anyway. Back in the css you add:

    .entry img {
    border:1px solid #F00
    }

    #about .entry img {
    border:none;
    }
    That way, on the page with the id of "about" (or whatever you want to call it), the images inside .entry would have no border.
  • Exactly what Noah restated in detail is what I was referring to.