StylizedWeb

Subscribe to our updates:

A Design, WordPress and Tutorials Blog.

Dedicated to helping you learn the art and science of the web.

Create a CSS3 Button That Degrades Nicely

There was a time where creating a nice looking, scalable button required heavy use of images, the sliding doors technique and even some javascript. As it stands a lot of the modern browsers support the css we would like to use to create a nice looking button. Firefox, Safari and Opera all have support for rounder corners, box shadows and text shadows. What used to take six steps and lots of extra mark-up, images and css, now only takes three steps and some simple CSS3.

One of the great perks regarding this technique is that in the event that a user doesn't have a browser that supports the CSS that we will be using, they will still see a nice beveled button - it simply won't look quite as nice.

What We are Going To Do

To create a nice button we have a few major components:

  • A nice background gradient
  • Rounder corners
  • Some nice borders to give it a 3D effect
  • A drop shadow
  • A text shadow (for a nice touch)

In the end we will have a button that looks just like this, only with out using any images behind a few pixel background gradient (and when CSS gradients are supported we can even remove that!).

screenshot

The HTML


<p><a href="#">Example Button</a></p>
<p><a href="#">Example Button</a></p>
<p><a href="#">Example Button</a></p>

As you can see the HTML is very basic, we essentially just need an anchor tag and text. The paragraph is there just to be semantic.

The CSS


.css3button a {
     background: url(background.gif) bottom repeat-x #9eabb3;
     padding: 5px 10px 5px 10px;
     text-align: center;
     font-weight: bold;
     color: #fff;
     text-decoration: none; border: 1px inset #aaa;
     -webkit-border-radius: 8px; width: auto; -moz-border-radius: 8px;  -khtml-border-radius: 8px;  border-radius: 8px;
     -moz-box-shadow: 1px 1px 1px #666;  -webkit-box-shadow: 1px 1px 1px #666;  box-shadow: 1px 1px 1px #666;
     text-shadow: rgba(0,0,0, .5) 0px -1px 0px;
      border-top: inset 1px #ccc; border-left: inset 1px #ccc; border-bottom: solid 1px solid #000; border-right: 1px solid #666;
}

.css3button a:hover  {
     background: #999;
     text-shadow: rgba(0,0,0, .5) 0px 1px 0px;
}

The CSS is a bit more complicated, but still fairly simple. We are really just adding a repeating background image, adding some rounded corners, as well as box and text shadows. The borders add a bit more depth / shading and ensures that if the CSS properties are not supported that the element still retains a beveled appearance.

background

The background image is simple gradient to give the button some depth, in this case I used the following image:

That Simple

That is how easy it is. If you want to play around with the borders you can end up with some pretty nice effects as well.

Examples

Example Button

Example Button

Example Button

Example Button


Leave a comment on Stylized Web Have some feedback? Leave a comment

78 Comments So Far

  1. By Alexander Kulikov posted on October 8, 2009 at 4:51 pm

    You can even add shadow for ie
    a {
    zoom:1;filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=1, OffY=1, Color=’#666666′);
    }

    :)

  2. Great tip Alexander, I will give that a shot!

  3. nice trick there. haha pretty cool!

  4. great outcome in such a simple way! I loved to see the proper way to support old browsers.

    Thx :)

  5. Pingback: Create a CSS3 Button That Degrades Nicely | Design Newz

  6. Pingback: 88 liens sur Wordpress, jQuery, typographie, CSS, webdesign …

  7. Pingback: GuyTouch » 88 lien pour Worpress, jquery, javascript, tout pour le web

  8. Thanks for the tutorial definitely something that I am keen to put to use soon.

  9. Pingback: Podcast #75: Jeremy Keith Interview, Google Wave « AccessTech News

  10. Pingback: Podcast #75: Jeremy Keith Interview, Google Wave « The BAT Channel

  11. Pingback: Больше, больше эффектов c CSS3! | rotorweb.ru | Проблемы и решения в Web-дизайне

  12. Thank you good article

  13. Pingback: Designing CSS Buttons: Techniques and Resources - Smashing Magazine

  14. Pingback: typoglyphic.com » Designing CSS Buttons: Techniques and Resources – Smashingmagazine.com

  15. Pingback: Designing CSS Buttons: Techniques and Resources | Buddy's Blog

  16. Pingback: Designing CSS Buttons: Techniques and Resources | Buddy's Blog

  17. Pingback: Designing CSS Buttons | Rolandyh Blogging

  18. This is awesome! nice job I love it!

  19. Pingback: All about Buttons, Buttons … & Buttons (CSS, Glowing, Javascript, Advance) | Ajax CSS and WEB2.0 Resource Directory. Ajax Effects, Components Drag Drop, CSS Gallery, AJAX CSS PHP Tutorial AjaxCSS.com

  20. I personally like it the only issue i see is that background image being to small, however I am on Chrome Mac Beta currently and they have some styling issues to work out that I know of .

  21. great outcome in such a simple way! I loved to see the proper way to support old browsers…

  22. Pingback: 20 CSS3 Tutorials and Techiques for Creating Buttons - Speckyboy Design Magazine

  23. Pingback: 20 CSS3 Tutorials and Techiques for Creating Buttons « qeqnes | Designing. jQuery, Ajax, PHP, MySQL and Templates

  24. Pingback: 20 + CSS3 Tutorials and Techiques for Creating Buttons | Seventy Seven magazine

  25. Pingback: 10 Amazing CSS3 Tutorials and Techiques for Creating Buttons | denbagus blog

  26. Pingback: 20 CSS3 Tutorials and Techiques for Creating Buttons | The New Drop

  27. Pingback: 20 CSS3 Tutorials and Techiques for Creating Buttons | The New Drop

  28. Pingback: 20 CSS3 Tutorials and Techiques for Creating Buttons | The New Drop

  29. Pingback: Designing CSS Buttons: Techniques and Resources | WebsGeek

  30. Pingback: Bookmarks for March 15th from 01:20 to 01:23 | Travis' Blog

  31. Pingback: Create a CSS3 Button That Degrades Nicely | LearnersTutorials

  32. Pingback: 20 CSS3 Tutorials for Creating Buttons | KSSP

  33. Pingback: Harika Css3 menu dersleri | web Design Source

  34. Pingback: Harika CSS3 Menü Dersleri | Sorbize

  35. Pingback: 45 Resources & Tutorials for designers and developers | Webdevtuts

  36. Perfect, thanks

  37. Pingback: 40 + Awesome and Essential CSS3 Tutorials, Techniques and Resources to Learn | Design | Webdesign, website & webshop maken portfolio

  38. Неплохие примерчики.

    rusio.net

  39. %100 Doğal ve hiç bir yan etkisi olmayan Uzamax’ı keşfedin
    UZAMAX içeriğinde mineral ve vitaminler barındıran, doğal bitkielerden üretilmiş gıda desteğidir. İçeriğinde herhangi bir kimyasal ürün bulunmamakla birlikte tamamen doğal kurutulmuş bitkisel bir karışımdır. Sadece birkaç aylık kullanım kürü sonrasında bile uzamax’ın etkisini hissedeceksiniz.

    Uzamax kullanarak doğal yollarla bünyenize gerekli olan tüm besin, vitamin ve mineralleri vücudunuza almanızı sağlar.izlanda yosun hapı

  40. Pingback: 原版 Readability Bookmarklet « 二師兄的筆記部落格

  41. Pingback: Today in Web » 15 Excellent Resources for Creating CSS3 Buttons and Menus

  42. Pingback: 150+ CSS3 tutorials and exercises for web developers « Design and Development tuts – TutorialShock

  43. Pingback: PandaDesignRo.com » Cool list of css3 buttons without using any images

  44. Pingback: Diseño Web: 10 colecciones de botones CSS3 listos para usar | CreativaSfera - Sandra Guerrero Sanmartí

  45. Pingback: Pop References In Britney Spears’ ‘I Wanna Go’ Video « dariushoper

  46. cappotti, sciarpe, abiti, stivali, abbigliamento spotivo ed invernale, calde felpe ed eleganti maglioni Moncler.Se non hai voglia di muoverti puoi acquistare on line.

  47. Too complicated production process and adornment often gild the lily, will attract the attention of the viewer to marriage gauze details and ignores the mistress of the marriage gauze of beauty. Especially those the skirt pile of compose full of big flower, marriage gauze to look like. Don’t know So Europe and the marriage gauze of concise, easy advocate the style. Of course, the appropriate bead embroiders, the bud silk, bowknot, ribbons is also essential to marriage gauze of the pen that nods eyeball. As if some brand clothing of the AD copy: contracted and not simple.

  48. Pingback: CSS3 tutorials, 150+ exercises for web developers

  49. Pingback: CSS button, 110 best!

  50. Pingback: 150+ CSS3 tutorials and exercises for web developers - DesignShock

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>