want to style image tag for one set of images but not others

Discussion in 'CSS' started by driven, May 8, 2007.

  1. #1
    on my blog here;

    I am trying to apply a margin of 5px to the big house image that you see in the first blog entry, Luxury Mansions. My code looks like this;
    a img, img a {
    	margin: 5px;
    	}
    Code (markup):
    Simple enough, right?

    But then I notice that that will affect the image in the upper right hand corner of my banner. In fact, it affects my other images too such as the orange banner in the sidebar. The css for that img looks like this;

     a img.showcaseimage, img.showcaseimage a {
    border:5px solid #002F2F;
    float:left;
    margin-right:5px;}
    Code (markup):
    What should I be doing so that my other images don't receive that extra margin of 5 pixels?
     
    driven, May 8, 2007 IP
  2. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #2
    Go into the blog post and edit it, and give it (the anchor for the image) an id and apply the margin to the ID? you can specify each of your blog entry images, but that would obviously not affect only the first blog entry.

    <a id="luxury-mansion-pic"><img /></a>

    a#luxury-mansion-pic img { margin:5px; }
     
    soulscratch, May 8, 2007 IP
  3. driven

    driven Well-Known Member

    Messages:
    400
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    138
    #3
    yes, but isn't that a very inefficient way of doing things- styling every individual pic in my blog post? I should note that this site is going to be very image-heavy and filled with lots of photos in the blog post.

    isn't there something I could do to the top right hand photo instead?
     
    driven, May 9, 2007 IP
  4. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #4
    You said you wanted to style that particular image for that particular post. You did not mention anything about other images in blog posts, therefore the solution I recommended fits. If you want to apply the same style, then just assign a class to the anchor which contains the <img /> and be specific in your selector, and style the image.
     
    soulscratch, May 9, 2007 IP
  5. bacanze

    bacanze Peon

    Messages:
    2,419
    Likes Received:
    127
    Best Answers:
    0
    Trophy Points:
    0
    #5
    As soulscritch said, just create a class and apply it to the image(s)
     
    bacanze, May 9, 2007 IP