Tutorials

Latest Word » Tutorials » Have Fun w/ Borders – Beveled, Pressed, & More!
css-border-tricks

Have Fun w/ Borders – Beveled, Pressed, & More!

Tags: ,

Since I released my new redesigned blog, a lot of people have asked me how I styled the pressed effect on my category navigation. I would like to share some simple border style tricks to get various effects for your next project.

Light Shadow

CSS Borders Light Shadow
A simple light shadow effect can be achieved with using shades of grey with borders. With CSS3 you can achieve a real shadow effect using box shadow, but this is a clean and simple way that works in all browsers.

CSS
.shadow {
	padding: 20px;
	border: 1px solid #f0f0f0;
	border-bottom: 2px solid #ccc;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
}

Pressed


CSS Borders  - Pressed

The pressed effect is very similar to the CSS Letter Press technique but we rely solely on border colors to achieve the effect. Add some CSS3 rounded corners and you can achieve a very clean pressed look to your layouts.

CSS
.pressed {
	color: #fff;
	padding: 20px;
	background: #111;
	border: 1px solid #000;
	border-right: 1px solid #353535;
	border-bottom: 1px solid #353535;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
}

Beveled


CSS Borders - Beveled Images

This technique is very similar to your double border technique commonly used with images. With a little bit of tinkering, you can achieve a subtle beveled effect using the outline property.
CSS

img.light {
	outline: 1px solid #ddd;
	border-top: 1px solid #fff;
	padding: 10px;
	background: #f0f0f0;
}
img.dark {
	outline: 1px solid #111;
	border-top: 1px solid #555;
	padding: 10px;
	background: #333;
}

Indented Lines


CSS Borders - Indented Lines

I use this technique often when creating vertical menus and lists. Its a simple combination of top and bottom borders with different shades of the background color. Keep in mind the first-child and last-child CSS selectors are not supported by older browsers. You can read more about this here. To get around it, you can use some jQuery to support older browsers.
CSS

#indented ul{
	margin: 20px 0; padding: 0;
	list-style: none;
}
#indented ul li {
	border-top: 1px solid #333;
	border-bottom: 1px solid #111;
}
#indented ul li:first-child {border-top: none;}
#indented ul li:last-child {border-bottom: none;}
#indented ul li a {
	padding: 10px;
	display: block;
	color: #fff;
	text-decoration: none;
}
#indented ul li a:hover {background: #111;}

Related Articles

Related Posts

Author Bio

My name is Soh Tanaka and I am a Los Angeles based designer/front-end developer specializing in CSS driven web design with an emphasis on usability and search engine optimization. I also run a CSS Gallery which is updated daily with the best CSS websites from around the world. Come check it out!

You can learn more about me or Twitter  Follow me on twitter for more updates and resources!

Did You Enjoy This Post?

subscribe  Subscribe via RSS or by email to get all upcoming tutorials and articles delivered straight to you.

+ Add Comment53 Peeps Have Spoken Their Minds...

  1. Ben Stanley

    Awesome! Thanks Soh…. great tricks

  2. Jack Rugile

    I love the indented lines. I definitely want to utilize that style in an upcoming project. They look great on your sidebar here. It is a very subtle, but powerful effect.

  3. Manmohanjit Singh

    Wha.. Not bad.

  4. Pavel Ciorici

    Nice tricks ;)

  5. Fred

    Very simple yet nice tips :D

  6. anasxz

    wow!.. everything in css..

  7. Joe

    Thanks for the useful tutorials! Borders and shadows add dimension and depth to an increasingly flat web. A couple years ago the USPS sent out a promo card around Christmas. Every object on the card had some kind of shadow or border and it really made the piece come alive, which isn’t easy to do on paper. I was so impressed I saved it. If I can find it now, I’ll scan and send you a copy, or maybe post somewhere on my site. But again, thanks for the CSS tricks. I’ll be sure to use them in the future :-)

  8. Seth

    Great tips. I’ve noticed small touches like this add depth to layouts that would otherwise be pretty vanilla. Thanks!

  9. Steve

    Very useful tricks. Thanks Soh!

  10. Kennyboy7

    Wicked post I was just about to figure this out of a site I’m working on. It’s like you read my mind, thanks.

  11. Montana

    Really nice technique! I have been using box-shadow with inset lately to achieve similar results, but yours is cross browser!

  12. javi

    Tanaka-san,

    thought you will talk about the black blackground effect. Great tuto though…arigatou gozaimasu.

  13. Alex Flueras

    Thanks so much. This is awesome!

  14. DheTemplate

    Nice post. no need image again.. :-)

  15. Beben

    i’m enjoy this post :D ;)

  16. Andrew Ckor

    But if you have white or black bg color, you cant do these!!:P

  17. Soh

    Why not? You can just use diff shades of the background color ;-)

  18. Kevin

    Very helpful, thanks!

  19. Mike Mai

    thanks for this in-depth look on shadows, very helpful as usual.

  20. Pato

    Simple and great! Thank you.

  21. Anything Graphic

    Sweet dude! I am in a redesign and was going to use images for this effect… Now I don’t have too! Yay :-)

  22. Shaun

    Some really great tips, and a really nice site too man. :)

  23. Chris

    I just recently discovered your blog, all quality posts.
    Keep up the good work!

  24. Theo

    Great tips, these small details are very important for a good looking site. Thank you !

  25. Wesley Terry

    WOW. I always thought these were image based. Really good stuff!

  26. Carpus

    Ampuuuuhhhhhhhhhhh!!!great tutorial!

  27. polly

    I would like to ask about how do we add border(pressed & bevel)around image….irregular image especially…….thnks….

  28. Julien

    Always great tips

  29. sanjay

    nice one soh! thanks.

  30. Drazen Mokic

    Thanks very much, this is great! Especially the indented lines, how often designers using images for that…

  31. Jae Xavier

    Great use of CSS. A lot better than slicing, dicing, and well you get the point :)

    Thanks!

  32. dwi

    great trick soh..simplicity..but sorry,can you make a tutor about your top nav that like sliding effect?I like that..

  33. ardianzzzz

    hey, thats cool!
    twothumbs, like this!

  34. jr

    love the tuts

  35. Saifu

    good tips… working ie….

  36. David

    I love all your tutorials.

    Is there a way to get this to work with IE6/7 as well? I’m amazed with how well your site works with older IEs. Mine looks like absolute crap as soon as you leave Firefox/Safari/Opera.

  37. Ajith Paul

    Hey Soh,
    Cool trick.. I have a question about your AVATAR trick when you see this plz answer me..!! you use a png image above the avatar, so now I can’t save that image by using right click option(Save Image As). So is it possible by using a png image just like you did to prevent copying images from users/visitors..actually this is the technique adopted by most of the stock-photography sites such as Corbis.com

    Regards.
    Ajith Paul

  38. Nikki

    nice work!

  39. ChrisJ.

    ‘Been wanting to learn this for a long time, thanks a bunch!

  40. Mexican Musashi

    Have Fun w/ Borders?

    That’s racist!

  41. Espreson

    Why! Lots of people still use IE6 or IE7….?
    Evolution of HTML5 and CSS3 will not be visible until death of those Browser…
    This trick or method is futuristic…

  42. champico

    Another great tutorial, thanks !!!

  43. Day Day

    Nice tips will definitely use these in the future thanks!

  44. satrya

    Wow,. nice tips.
    Great job !

  45. Jont

    Top work – the indented line technique is cleverly simple.

  46. Harish Sharma

    Awesome!

    I have used the styles that you have mentioned here but not the way you have done.

    I will also try this technique.

    Thanks! Soh for posting such nice articles.

  47. Amanda

    Love your site. Very good tips

  48. Mubeen

    Awesome tricks, as always :)

  49. Nikola Dadić

    Awsome article, thank you!!!

  50. Bogdan

    Great article mate, this is a great trick for using those styles.

  51. deepak

    awesome n very simple trick !! gr8 buddy !
    every time i read ur post.. i just fall crazy 4 ur work.. !!

  52. Huw Rowlands

    Wow thanks for these tips!

  53. Hitesh Chavda

    Excellent Tips, Please Keep it up, Thanks.

Speak Your Mind...

Post HTMLNeed to Post HTML Code? Use Postable to post code friendly html. *Wrap all html code in <pre></pre> tags.
Post HTMLNeed to Keep Updated with Comments? Subscribe to comments now.

CSS Gallery