written on:21 Feb, 2008 by Alen Grakalic
Custom Double Solid Borders for Images
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed
In this brief tutorial I will show you how to create solid double borders for images and style them however you wish.
We are not going to use border-style:double; As we know these are not easy to control.
Imagine a situation where you want outer border on the image to be 3px thick and green and inner border 1px thick and yellow. How would you achieve this? And further more, how would you achieve this with no additional markup?
The Trick
What we'll do here is use css border property for outer image border and we'll fake the inner border using combination of background and padding properties.

First we add a border property to the image and set the values
img{
border:2px solid #72a143;
}
If we set the padding to 1px and add a yellow background,
img{
border:2px solid #72a143;
padding:1px;
background:#ffeda5;
}
the image will receive another "border" inside the real one.
That's it! :)
About the author:
Designer, developer and a passionate standardista with large experience in all types of front-end work. Started to get involved with web in 1999. and turned freelance in 2005., the same year he started Css Globe. Alen's work has been featured on numerous css galleries including famous Css Zen Garden official list. Available for contract work.
Enjoyed the article?
Subscribe to our RSS feed or share it with your friends.
Delicious | Digg | Stumble | Reddit | Float | Subscribe to RSS Feed
Comments
Subscribe
Join 3800+ subscribers and receive our content instantly.
Follow us on Twitter
Want to be the first to know when a new article is published?
Sponsors

PSD to HTML: You Design - We XHTML

Sitegrinder 2 Photoshop Plugin

FlashDen - The Best Flash Files

Look Professional with FreshBooks
Recent Articles
- Easiest Tooltip and Image Preview Using jQuery
- 4 Uber Cool Css Techniques For Links
- CSS do's and dont's Part 1: CSS Selecting
- Easy Scroll: Accessible Content Scroller
- Pure CSS Animated Progress Bar





Ryan on 21 Feb, 2008 wrote:
img{
border:1px double #72a143;
padding:1px;
background:#ffeda5;
}
Agahmemnon on 21 Feb, 2008 wrote:
warnis on 22 Feb, 2008 wrote:
PinkPetrol on 22 Feb, 2008 wrote:
Jermayn Parker on 22 Feb, 2008 wrote:
cssglobe on 22 Feb, 2008 wrote:
Sarah on 22 Feb, 2008 wrote:
Tobias Bleckert on 24 Feb, 2008 wrote:
outline: 2px solid #72a143;
border: 1px solid #ffeda5;
Marcelo on 25 Feb, 2008 wrote:
PiticStyle on 28 Feb, 2008 wrote:
emil on 29 Feb, 2008 wrote:
eXanock on 29 Feb, 2008 wrote:
Braintrove.com on 29 Feb, 2008 wrote:
gerard on 29 Feb, 2008 wrote:
ikram_zidane on 6 Mar, 2008 wrote:
aint it supposed to be 3px ?
Shaikh Sonny Aman on 8 Mar, 2008 wrote:
chears
meftahul sagor on 11 Mar, 2008 wrote:
Vance Bell on 22 Apr, 2008 wrote: