Treehouse: Grow your CSS skills. Land your dream job.

How do I apply a border to an image w/o it encapsulating the padding too?

  • # August 2, 2011 at 10:10 pm


    I have a block of images that I want to add a 1px solid #CCCCCC border to, but I have a padding: 10px 10px 0 0; and when I add the border to the image class it goes around the padding too. Here is a link to what I need to modify:

    Some of the images appear to have borders, but they were done in Illustrator and it seems like a waste of time when a CSS class could do the same thing easier.


    # August 2, 2011 at 10:19 pm

    Change the padding to margin and your set!

    # August 2, 2011 at 11:34 pm

    Thanks again! That was so simple. I can stop pulling my hair out now.

    # August 2, 2011 at 11:53 pm

    Padding sits inside the border and margin outside of it. Once you understand that it is easy!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.