Introduction to CSS3 - Part 3: Text Effects : 9th May 2008



The third part in this series on CSS3 will be delving into the new text effects. Typography is, without any doubt, one of the most important aspects to get right when designing a layout. Type can draw the reader through a page, give a certain impression, provide impact, be subtle, or aid in separating content.

CSS is already reasonably versatile in the way in which text can be displayed, but still constricts design in quite a few areas. CSS3 goes some way towards removing those limitations.

All the examples shown below can be seen at our CSS3 examples page. Many, however, can only be appreciated in the latest builds of various browsers:

View the live examples page

Text Shadow

Text shadows sound a little tacky, but it all depends how they are executed. When experimenting for this article I found some combinations to look terrible, and some to give an attractive, subtle effect. Shadows could definitely be put to good use in headings and titles – there are some great examples of their use at Matthias Kretschmann’s blog.

.text_shadow {
color: #897048;
background-color: #fff;
text-shadow: 2px 2px 2px #ddccb5;
font-size: 15px;
}

CSS3 Text Shadow

Word Wrapping

At present, if a word is too long to fit within one line of an area, it expands outside. This isn’t a very common occurrence, but does crop up from time to time. The new word wrapping ability allows you to force the text to wrap – even if it means splitting it mid-word. The code is incredibly straight forward:

.text_wrap {
word-wrap:  break-word;
}

CSS3 Text Wrapping

Web Fonts

Whilst these are not classed as a ‘text effect’, we are going to cover them here briefly. A Web Font is simply a way to use any font in your page, being downloaded automatically by the browser. This will be a revolutionary change to web design, which previously has been limited to 10-15 widely supported fonts. However, this new feature brings bring copyright into debate as only properly licensed fonts should be used.

Currently, the latest version of Safari (3.1) is the only browser supporting Web Fonts. Opera is suggested to be another which will soon be enabling support, and the others will no doubt follow at some point in the future. An example of how this could be achieved would be:

@font-face {
font-family: 'Name of the new font';
src: url('http://www.designshack.co.uk/fonts/font.ttf');
}

A few examples of pages have been mocked up using this technique. The following are examples in the vein of CSS Zen Garden, created by A List Apart. The linked versions will only work on certain browsers:

CSS3 Web Fonts CSS3 Web Fonts

In conclusion…

Many of the missing features of CSS2 have been rectified in this update. This article doesn’t cover all the additions in terms of text – if you’re interested, you can read more about the text module. All these additions are great when used in a subtle way, enhancing the typographic layout of the page.

The next article in this series will be expanding on some of the user interface enhancements in CSS3. Remember, to see live examples of these features, take a look at our CSS3 example page.

Other posts in the series


Comments and Discussion


On 9th May 2008 , steve said:

Safari 3.1 supporting Web Fonts perfectly.

On 9th May 2008 , David Appleyard said:

Thanks - I've updated the article to clarify Safari 3.1 supports them rather than WebKit.

On 9th May 2008 , kremalicious said:

Nice series of articles! Maybe you are interested in my article about the text-shadow property which includes some more informations for what you can do with it: Text-Shadow Exposed: Make cool and clever text effects with css text-shadow

On 9th May 2008 , kremalicious said:

oops, the tag didn't work, here's the link: http://www.kremalicious.com/2008/04/make-cool-and-clever-text-effects-with-css-text-shadow/

On 9th May 2008 , sumit said:

its gonna be awesome

On 9th May 2008 , Lut said:

Wow, web font looks fantastic. I'm really looking forward to see these things working in most used browsers. It's gonna be legen... :-)

On 10th May 2008 , Bigismall said:

Try this http://www.css3.info/

On 11th May 2008 , Alexander said:

The downloadable font feature is something that can save many people a lot of headache,hope it will be implemented on the browser majority soon... But I believe it could be easier just to specify font-family: url(http://mysite.com/myfont.ttf);



Add your thoughts



I'd like to be
inspired by:



Colour


Red Designs Blue Designs Green Designs Yellow Designs Brown Designs Orange Designs Brown Designs Grey Designs Multi Coloured Designs


Category




Layout


One Column CSS Layout Two Column CSS Layout Three Column CSS Layout Grid CSS Layout Other CSS Layout


I've got a
question...



What is Design Shack?

We showcase stunning CSS and Web 2.0 design, alongside resources and inspiration for you to succeed in the same way. We only offer the cream of great design, perfect for getting that spark of creativity going again.

Can you feature my site?

Of course - if it's up to the mark! Just fill in our simple form.

Can I help out?

We are looking for new people to help update and maintain the website alongside us. If you're interested, feel free to contact us.