Typography is often overlooked in todays design specifically by web developers. It really is a shame because CSS gives us so much control over our type. That being said, we our limited to certain “web safe” typefaces but that shouldn’t decrease our creativity. Here are a few CSS tips for typography on the web.
The Font Attribute
CSS provides us with the Font attribute, which is what allows us to tweak the text on our page. This is an overview of the syntax and how to effect text using CSS.
Font-size
Change the size of your font using font-size
font-size: 1.2em;
font-size: 12px;
font-size: 10pt;
Live Preview
- Font size is set to 1.2em.
- Font size is set to 12px.
- Font size is set to 10pt.
Font-weight
This is used to change the weight of your font (i.e bold, bolder)
font-weight: normal;
font-weight: bold;
font-weight: bolder;
font-weight: lighter;
Live Preview
- Font weight is set to normal
- Font weight is set to bold
- Font weight is set to bolder
- Font weight is set to lighter
Text-transform
The text-transform property allows you to apply uppercase, lowercase, and capitalize effects to your text.
text-transform: capitalize;
text-transform: uppercase;
text-transform: lowercase;
text-transform: inherit;
Live Preview
- Capitalizes the first letter in every word
- Allows your html to be lower case the converts it all to uppercase characters
- ALLOWS YOUR HTML TO BE UPPERCASE THEN CONVERTS IT TO LOWERCASE, THIS WAS TYPED IN ALLCAPS
- inherits the text-transform property from its parent element
Text-decoration
The text-decoration property allows you to underline, overline and put a line through your text
text-decoration: normal;
text-decoration: underline;
text-decoration: overline;
text-decoration: line-through;
text-decoration: blink; (DO NOT USE)
Live Preview
- Text decoration set to normal
- Text decoration set to underline
- Text decoration set to overline
- Text decoration set to line-through
- Text decoration set to blink ( Only works in Firefox and Opera )
Font-Variant
The Font variant property allows you to create the small-caps effect which capitalizes the letters then decreases the font size.
font-variant: normal;
font-variant: small-caps;
font-variant: inherit;
Live Preview
- Font Variant set to normal
- Font Variant set to small-caps
- Font variant set to inherit
Creating Drop Caps
Creating drop caps is easy with CSS. There are multiple ways to create the drop cap effect but I am going to show the most efficient way. To create them use the :first-letter pseudo-element which only effects the first character of a given element.
<p class="dropcaps">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p>
p.dropcaps:first-letter {
font-size: 340%;
margin: 8px 5px 0px 0px;
float: left;
font-weight: bold;
width: 1em;
}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
Creating Attractive Paragraphs
For more attractive paragraphs use Robert Bringhurst’s method which states: Take your font size and multiply it by 30 to get the width of your paragraphs.
For example if your font size is 12px, multiply it by 30 and you get 360px which should get you approximately 65 characters per line.
Incorrect Measure
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
Correct Measure
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
Line-height Examples
Line height dictates the amount of space in between each line of text. A good rule of thumb is to make the line height 6-7px bigger than your font-size.
For example if your font size is 12px, add 6px to the font size and you get your line height, which would be 18px.
Incorrect Line-Height
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
Correct Line-Height
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
Cleanly Emphasize Text
Underlines should only be used on text that is linking to something or somewhere. Italicizing text is a cleaner alternative.
Incorrect example
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
Correct example
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
Looking forward – CSS3
There are already some exciting features that you can incorporate into your designs dealing with type in CSS3. Of course some of these new features do not work in IE, but your probably used to nothing working in IE anyway so give these a shot.
@Font-face
@font-face allows you to upload a raw font file to your web server and link to it in your external CSS file, then apply it to any type on your site.
This feature is the biggest one dealing with type, but along with it’s upside comes its downside. There are only a few fonts that you are “allowed” to use because of licensing issues. The fonts that are CSS3 safe can be found here.
Usage of @font-face
In this example I put a folder in the root of my server called font. First you need to declare the @font-face attribute which imports your font file and then you can use the font name to effect any other elements.
/* Declaring the font */
@font-face {
src: (font/diavlo.otf)
}
/* Applying the font to an element */
h1 {
font-family: diavlo, Arial;
}
Text-Shadow
The text shadow attribute takes away the need to create drop shadows for certain elements in photoshop and gives you dynamic drop shadow control. Of course this attribute is only supported in Safari, Chrome, Firefox and Opera.
Example Heading
p {
font-size: 2em;
font-weight: bold;
color: #777;
text-shadow: 1px 1px 1px #222;
}
Example Heading 2
p {
text-shadow: 2px 2px 2px #222;
}
Example Heading 3
p {
text-shadow: 1px 1px 5px #FFF;
}
The Challenge
The techniques in this article are just guidelines. Take them and implement the features you like into your web designs. Typography is extremely important and can absolutely ruin a beautiful design. Don’t let that happen to you bookmark this guide!



January 13th, 2010 at 4:21 pm
Some great tips Shane, thanks for the post

Liam McCabe´s last blog ..Contact form or mailto link?
January 13th, 2010 at 4:36 pm
A good overview. A few thoughts/questions:
What do you use for font-size? I started out using pixels and then moved to ems because it was better for screen zooming but with full page zooming in most browsers, I’ve leaned back towards pixels.
Text-decoration:blink should be banned from all browsers.
I love the possibilities with CSS3 especially in the type arena. I’m using a little text shadow on my upcoming redesign. What is your favorite CSS3 text effect?
Chris Thurman´s last blog ..Wet Logos: Showcase of Logo Designs Featuring Water
January 13th, 2010 at 4:42 pm
This post is absolutely fantastic and a great reference – bookmarked.
I really like the live examples and some of the common guidelines you cover.
Murlu´s last blog ..The Beginner DJ Equipment Guide: Building Your First DJ Setup
January 13th, 2010 at 7:01 pm
Nice review, however I believe that there are three missing CSS elements (2 attribute, 1 selector) to make it “Ultimate” :
- font-variant
- letter-spacing
- :first-letter (to create drop caps)
Léo´s last blog ..8 conseils pour gagner jusqu’à 5 points de PageRank en quelques mois
January 13th, 2010 at 7:18 pm
Sweeet. Great tutorial. I think I will even print this out for future reference.
Tony´s last blog ..How to Track the Number of Clicks on Your Bit.ly Links on Twitter
January 14th, 2010 at 6:35 am
Nice guide man.

I can’t wait for CSS3 to be more widely accepted! Imagine the day you wouldn’t have to worry anymore about Internet Explorer… ahh one can dream
JP´s last blog ..10 Ways to Instantly Speed Up Your Website
January 14th, 2010 at 7:19 am
Nice one, bookmarked for future reference.
Thanks.
January 14th, 2010 at 6:02 pm
[...] The Ultimate Guide to CSS Typography [...]
January 14th, 2010 at 6:31 pm
[...] The Ultimate Guide to CSS Typography | Three Styles. [...]
January 14th, 2010 at 6:46 pm
I’m just entering the world of web development and I think this is a fantastic reference for manipulating font layout. I am really interested in @font-face and the ways it can be used. I blogged about it earlier this summer, so here’s another example as well as some visuals. http://www.monetspells.com/?p=218.
Thanks for the reference sheet. I am definitely going to bookmark it!
January 15th, 2010 at 10:38 am
Typography seems to be gaining a lot of momentum on the web, which is good and once css3 has been widely adopted, it will be a great tool to play with!
January 16th, 2010 at 12:10 am
Great!! Thanks so much for this
January 16th, 2010 at 3:16 am
wonderful post, thanks for share.
in fact, CSS3 can do more thing for typography. i agree with Leo says, and recommend the css3 multiple column.
January 16th, 2010 at 10:28 pm
Thanks Shane, what a great article!
January 17th, 2010 at 4:57 am
Great Tips Shane.
These must be handy and kept as printed page for easy reference anytime. Great for a novice or a pro equally. I agree that CSS3 has many more attributes which are not in older version especially regarding images and typography.
Keep up the good work
January 17th, 2010 at 4:31 pm
Nice roundup but you made a little mistake:
The copy text of the “Text decoration” paragraph is the same as in the “Text transform” paragraph.
January 17th, 2010 at 7:49 pm
[...] Read more @ The Ultimate Guide to CSS Typography | Three Styles. [...]
January 18th, 2010 at 3:09 am
[...] The Ultimate Guide to CSS Typography Typography is often overlooked in todays design specifically by web developers. It really is a shame because CSS gives us so much control over our type. That being said, we our limited to certain “web safe” typefaces but that shouldn’t decrease our creativity. Here are a few CSS tips for typography on the web. (tags: typography css webdesign tips) [...]
January 18th, 2010 at 7:19 am
[...] The Ultimate Guide to CSS Typography [...]
January 18th, 2010 at 11:03 am
[...] The ultimate guide to CSS typography (threestyles.com) [...]
January 18th, 2010 at 11:39 am
Great basic tutorial. Will keep coming back

Saptarshi´s last blog ..Geek Google and Helvetica
January 18th, 2010 at 11:39 am
Very good article men.
January 18th, 2010 at 12:33 pm
Hi,
Nice article, but would not call it ultimate. You left quite a bit out of it.
January 18th, 2010 at 12:34 pm
Nice guide!
January 18th, 2010 at 2:31 pm
@Chris
Currently my favorite is the text-shadow property, but @font-face is pretty exciting.
@Leo
I updated the article to include these properties! Thanks for the suggestions.
January 18th, 2010 at 7:51 pm
Great roundup of the font attributes and what they do.
There area couple things missing. First off, learning the correct order in the shorthand method for ‘font’ is necessary.
font: bold 11px/16px verdana, sans-serif;
Font Weight
Font Size
Line Height
Font Family
And if you’re wanting the ‘ultimate’ guide, you have to talk about using ems instead of pixels or points for uniform display and scaling across browsers.
This article is pretty much the gold standard:
http://www.alistapart.com/articles/howtosizetextincss/
Jason´s last blog ..Digging into Wordpress: Book Released
January 19th, 2010 at 5:00 pm
Great article. Doing a full redesign of my company’s site and using the Correct Measure and Lineheight concepts for sure.
January 21st, 2010 at 5:00 pm
[...] Ultimate Guide to CSS Typography: http://www.threestyles.com/tutorials/css-tips-for-better-typography/ Possibly related posts: (automatically generated)Sunline’s new exhaust is readySunline’s [...]
January 22nd, 2010 at 4:56 pm
Nice and well-explained article. Made me look at the @font-face thing.
January 22nd, 2010 at 6:43 pm
[...] Sam Horner sent me this very informative article on dealing typography using CSS. [...]
January 23rd, 2010 at 4:51 pm
[...] The ultimate guide to CSS typography “Typography is often overlooked in todays design specifically by web developers. It really is a shame because CSS gives us so much control over our type. That being said, we our limited to certain “web safe” typefaces but that shouldn’t decrease our creativity. Here are a few CSS tips for typography on the web.” [...]
January 26th, 2010 at 3:32 am
Thank you for this guide. This is really helpful to me.
I’m Korean web designer. So I’m always concerned about Hangul typography.
Hangul is little diffrent with English. But typography to deal with letters have a lot in common.
Your articl is very good guide for web typography.
January 27th, 2010 at 1:27 pm
[...] The Ultimate Guide to CSS Typography Typography is often overlooked in todays design specifically by web developers. It really is a shame because CSS gives us so much control over our type. That being said, we our limited to certain “web safe” typefaces but that shouldn’t decrease our creativity. Here are a few CSS tips for typography on the web. (tags: typography css webdesign tips) [...]
February 8th, 2010 at 11:49 am
This is a very nice little tutorial! Many of these techniques are sadly unknown or overlooked by so many designers. Bad typography can indeed ruin a site. I hate trying to read full-screen width text with not enough line-height. It ruins the usability and accessibility of a site.
Codesquid´s last blog ..Usable and accessible web design for the iPad
February 11th, 2010 at 9:03 pm
@Chris Thurman,
For many years now I have been using the percentage em reset concept for font sizing.
This is done by setting the body{} font-size to 62.5%, the theory being that 1em = 10px. It was years ago I read about this so I have long forgotten where this is written but I am sure it is documented in many places.
1em = 10px;
1.2em = 12px;
1.4em = 14px;
and so on.
This means you can use em to create scalable text but with more control over your understanding of what the size should be.
This if course doesn’t factor the differing size in text at any given size. Most fonts appear bigger/smaller even when they’re set to the same size.
verdana at 12px looks bigger than arial at 12px for example.
February 14th, 2010 at 12:35 am
Great Post! Thanks for sharing!
February 16th, 2010 at 12:09 pm
Wow! Great post.

aravind ajith´s last blog ..Zexee: A Free Sexy WordPress Theme!
February 21st, 2010 at 2:25 pm
[...] The Ultimate Guide to CSS Typography | Three Styles [...]
March 3rd, 2010 at 1:06 pm
Great tips. I’m bookmarking this one right away!
Thanks!