Occasionally when working with images in HTML it’s nice to have cool effects along the borders of the image. For instance, a nice drop shadow, rounded corners, etc. The problem is that usually to achieve these effects each and every image has to be taken into a photo application and altered. Which, even with batch actions, can be a time consuming and frustrating process. Further, if the design of the site changes in the future all the images have to be altered as well. Clearly there has to be a better way.
And there is!! By utilizing the CSS background property combined with the image tag and a few borders we get great looking image effects without ever having to alter content images! Let’s take a look at the final outcome before going further.
The key with this technique is to apply a standard background image to the background property of all “content images” in the CSS. From there we can make the effect show up by adjusting the padding of the img tag in the CSS. We’ll apply the effect width in padding.

For instance, if my drop shadow is 3px wide in the effect-image I am using (in this case thumb-bg.gif), then I would apply 3px of padding to the right and bottom of the img tag in the CSS. Or 4px if I wanted 1px of white space before the start of the content images.
In essence, every image that shows up has thumb-bg.gif appended to it as the effect. And the beauty is that thumb-bg.gif is only 1.3k, so it will load quickly and cache for all future images.
Alright, so here’s the raw CSS:
img { background: #fff url(thumb-bg.gif) no-repeat right bottom;
border-top: 1px solid #ddd;
border-left: 1px solid #ddd;
padding: 1px 4px 4px 1px;}
In this code I am applying the background effect to each image and then adding a gray border to the top and left of each image to complete the effect.
In the future as PNG’s and CSS 3 become more common this technique could be revised to be even more powerful. However, in the mean time it is a great way to save time on image editing while still adding a pop to your normal everyday images.