CSS3 features you can start using now

Written September 1, 2009. 14 comments.

We Own The Sky (Link) Credit: Jsonsw-7

Although CSS3 isn’t mainstream enough that we can adopt it wholly without regard, we can however start using it knowing that it will degrade gracefully enough with minimal impact on our designs.

Aside from beginning your familiarisation process with CSS3, another advantage is that as more browsers start to support it, users with supported browsers (Firefox and Webkit based browsers at time of this blog post) will start noticing the nicer ‘changes’ you’ve made to your web site.

If you want to take advantage of some of the cool stuff made possible by CSS3, by all means start doing it now. Here’s a few you can start using immediately.

Rounded corners

These look particularly nice on form fields, but of course you can also use them on other HTML elements. If the browser doesn’t support CSS3 the user will simply see standard squared corners. The chances are you have been using square corners on your divs and form fields anyway so there’s no love lost, but now they will look much nicer in supported browsers.

rounded_corners.gif

-moz-border-radius: 5px; /* The radius for Mozilla */ 
-webkit-border-radius: 5px; /* The radius for Webkit */ 

Multiple columns

Once the domain of printed media, multi column content areas can look right at home on a web page as well, and CS3 will let you do it without the need to place each column floating in a div. What happens in an unsupported browser? Thankfully nothing to drastic. The text will just appear as a standard paragraph. But you will just need to bear that in mind when you design the page. FYI, as far as I know this only works in Firefox.

multi_columns.gif

-moz-column-count: 3; /* Number of columns */ 
-moz-column-gap: 1em; /* Space between each column */ 
-moz-column-rule: 1px solid black; /* Colour of the border between the columns */ 

Box shadows

Bye-bye transparent PNG’s: It’s been nice knowing you. Actually transparent PNG’s will always have a use in modern web design, but the CSS3 Box shadow property means they won’t be needed to create a drop shadow under a modal box. As with everything else mentioned in this article, graceful degradation occurs and in this case, and the user simply won’t see the drop shadow.

Note that the box shadow requires at least 3 values to work but no more than 4.

box_shadow.gif

width: 250px; 
padding: 10px; 
-webkit-box-shadow: 7px 7px 10px #ccc; /* The coordinates of the shadow, blur radius, and the colour (Webkit) */ 
-moz-box-shadow: 7px 7px 10px #ccc; /* The coordinates of the shadow, blur radius, and the colour (Mozilla) */ 

Update: box-shadow has been removed from the CSS3 spec.

Text shadow

Once the domain of Photoshop noobs during the last millennium, thanks to CSS3 drop shadows on text are back to haunt every self respecting designer. Seriously though, this one will get abused like you won’t believe and once the Management sees it, they will want it on everything. Let’s keep it our little secret.

text_shadow.gif

font-size:2em; /* Font size */ 
text-shadow: 2px 2px 3px #999; /* Coordinates, blur radius, colour */ 

Fonts

While it’s still not a typographers dream, CSS3 does provide far greater control over type. The ability to use any font on your site will also open up a huge can of legal worms, so to avoid any legal hassles it might be best to only use fonts that are free. And with fonts you’ve purchased, you might want to check if the licence extends to you using it on the web in this manner.

font_face.gif

Using a font is as easy as:

@font-face { 
font-family: "Days"; /* The name of the font sans the extension (to be referenced further down in your style sheet when required) */ 
src: url("Days.otf") format("opentype"); /* The path to the font, absolute or in this case, relative to the document */ 
}

h1 { 
font-size:1.6em; /* The font size */ 
font-family: "Days", Helvetica, Sans-Serif; /* Remember that reference to the font I made earlier? This is it. */ 
} 

Mixing it all up

Now you can try and be a bit more creative. The example below shows some of the CSS3 elements demonstrated earlier in one single containing div.

mixed.gif

That wasn’t so hard now was it? Consider this your first very basic introduction to CSS3. Of course there’s a lot more to it than I’ve shown here, but these will get you started before you move onto something a bit more complex. By the way, here’s a sample I prepared earlier:

css3_demo.zip (2k)

Who is That Web Guy?

Michael is a veteran web designer / developer / usability evangelist, practitioner of W3C guidelines, and currently head of the web dev unit at Stormbox, a branding and creative communications agency located in Perth, Western Australia.

14 Responses to CSS3 features you can start using now

  1. Anderson says:
    The font-face is the most appealing out of these. Thanks for the nudge and I reckon it’s about time I started using some of this stuff.
  2. Anders says:
    BTW why did you use images instead of the actual css3???
  3. That Web Guy says:
    Thanks Mr Anderson – I used images so that people viewing this page on browsers without CSS3 support can see what happens.
  4. Jillinity D. says:
    Will font-face work with true type fonts?

    Love your work.
  5. CSS Babe says:
    Excellent stuff once again. Q: Would search engines be able to pick up on the font used? To me it would seem easy for the author of a Helvetica for example to search for sites using that font.
  6. Harun Smrkovic says:
    OH MAN!
    Thanks for the tips ;)

    I am so excited :) :) I personally think the font option is the best yet.
  7. That Web Guy says:
    I don’t think so. I just tried to search for my style sheet through Google and it found nothing – even when I type in the direct path. As far as I know, search engines ignore style sheets, but they pay attention to inline CSS.
  8. CSS Gallery says:
    Great list. Thank you for the info. I still seem see errors come up with validation for those things even when CCS3 is selected.
  9. Harun Smrkovic says:
    I see you’ve added shadow to your titles :D
    Way to go (Y)
  10. That Web Guy says:
    …and to links in the article :-)
  11. Harun Smrkovic says:
    Man, I can’t make this work :(
    I uploaded your example with my truetype font and it just loaded sans serif instead of Harabara.ttf :D :D
    :(
  12. That Web Guy says:
    Maybe try making the path to the file absolute? Upload a zip somewhere if you want me to have a look at it. Or chat with me on my new instant messenger account: messenger@thatwebguyblog.com
  13. Sivaranjan says:
    This is an incredible post. Its amazing to see what CSS3 can do , at the same time its sad a lot of customers still want IE support which sucks at CSS3 big time. I am taking the liberty of adding this article to my CSS aggregator site. Hope you dont mind. :)
  14. Daniel says:
    Nice, I have been using rounded corners since CS3 has come out.

Leave a Reply

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

two + = 6