Feature
Post

Category
Design


Transform your text with text-transform

Text-transform is an incredibly useful CSS property, yet also one of the most underused. Here are its possible values (with examples):

none : Default. Defines normal text, with lower case letters and capital letters
e.g. The quick brown fox jumps over the lazy dog.

capitalize : Each word in a text starts with a capital letter
e.g. The quick brown fox jumps over the lazy dog.

uppercase : Defines only capital letters
e.g. The quick brown fox jumps over the lazy dog.

lowercase : Defines no capital letters, only lower case letters
e.g. The quick brown fox jumps over the lazy dog.

How useful is text-transform? Well, let’s say you want all of your h3 headers to be in all-caps on your blog. You could type it in with all-caps in your blog title field, but there are a few problems there:

  • You would have to do this every time you wrote a blog post.
  • Should you decide, in the future, that you don’t want all h3 headers in uppercase- you would have to rewrite everything.
  • For blogs or sites with multiple authors, you would have to make sure each author knows to type in uppercase for a certain field.
  • The search engines that index you will show your titles IN ALL CAPS, which looks kinda spammy.

So here’s what you do. You write your blog titles normally, and in your stylesheet you add:

h3 {text-transform:uppercase}

This way, your titles are in uppercase. You can transform them anytime by changing uppercase to capitalize or lowercase. You don’t need to tell other authors which things to capitalize or type in all uppercase. And the search engines will publish them normally in their results. Everybody wins.

And what if you want your blog title h3s to be uppercase, but not the h3s in your sidebar? That’s where none comes in. Add something like this to your stylesheet:

#sidebar h3 {text-transform:none}

and voila! All h3 titles in your sidebar revert back to normal casing.

Do you use text-transform? What are your favorite underused CSS properties?


  1. By Harry Roberts posted on May 28, 2009 at 9:17 am
    Want an avatar? Get a gravatar! • You can link to this comment

    I champion its use too, definitely an annoyingly underused property.

    There are far more beneficial examples to the ones you outlined though:

    One is copy/paste. Because you want it to appear all caps, doesn’t mean it should be all caps everywhere.

    Secondly, and more importantly, is the concept of separating style and content. All caps is classed as styling, rather than content. BBC is always capitals, so that should be typed in caps. THIS IS A SENTENCE is only in caps for stylistic purposes so CSS should be used to style that.

    Only type in caps if it has to be at all times (ie BBC, SCUBA, RADAR, ITV, RSPCA etc), and if it’s for stylistic/aesthetic/arbitrary purposes, use CSS to transform it.

  2. By Bill Lowden posted on May 28, 2009 at 4:44 pm
    Want an avatar? Get a gravatar! • You can link to this comment

    Good info! And good samples of using text-transform. Thanks for taking the time to put it together for us.

  3. By My Amazing Weight Loss Story posted on May 29, 2009 at 4:00 am
    Want an avatar? Get a gravatar! • You can link to this comment

    Thanks for writing, I really liked reading your most recent post. I think you should post more frequently, you obviously have talent for blogging!

  4. By Dan Tarrant posted on June 3, 2009 at 11:03 am
    Want an avatar? Get a gravatar! • You can link to this comment

    I use text-transform all the time for all the above reasons. A very powerful property that’s very under-used.

  5. By Pieter de Jong posted on June 6, 2009 at 8:13 pm
    Want an avatar? Get a gravatar! • You can link to this comment

    I use text-transform: uppercase a lot since a year, google really likes it.

  6. Trackbacktext lower in FF than in IE, Chrome, Safari - Graphic Design Forum and Web Design ForumLower Case Months Plugin for WordPress | Jon Raasch's Blog