Lori's Web Design
my facebook     my twitter     My blog

How to Add a Border Around an Image with CSS


Sometimes, when building a web page, you want the image to look like it has a border like a photograph when you get film developed. The following will show you how to add a border around images using CSS:


Image Border with White Background

Add to your CSS file or the head tag:

.imgborder
    { background:#ffffff;
    padding:12px;
    border:1px solid #999999; }

Add this class (imgborder) to your image tag in the html file:

<img src="images/IMAGENAME.jpg" width="200" height="256" border="0" alt="" class="imgborder">
border around image




Image Border with Transparent Background

The padding around this border is a bit thinner than the one above but you can make it wider by changing the padding.

Add to your CSS file or the head tag:

.img-border {
    background:transparent;
    padding:8px;
    border:1px solid #4D1C19; }

Add this class (img-border) to your image tag in html file:

<img src="images-tips/pinkrose.jpg" width="200" height="256" border="0" alt="" class="img-border">
image with border and transparent background




order SEO analysis

Also see Add Frames around Images with CSS

Return to CSS TIPS

Lori Eldridge
Copyright © July 31, 2011
All Rights Reserved




 
Serving Spokane, WA, Colfax WA, Deer Park WA, Medical Lake WA, all of Eastern WA and across the USA

Lori's Web Design Spokane: 509-443-8693
or Colfax: 509-397-6000

Copyright © 2000 - 2012
All Rights Reserved