StylizedWeb is a web design trends and tutorials blog, maintained by Ross Johnson who also runs a web design company and design blog.

Categories Archive

Popular Posts
Advertisement
Basecamp The Web Design Sketchbook
Najbolje ponuda IT poslova u Srbiji na itposlovi.info Advertise on Stylized Web

How to Create Inset Text with CSS3

add to Save to Delicious Save to Stumble Save to Digg

The new CSS3 properties being adopted by browser manufactures gives us whole new ways to creatively style our websites with out having to resort to images, javascript or flash. As more people start to play with the CSS3 properties you can expect new ways to use them that might not be in ways that you would imagine.

In this case we are going to use the text-shadow property that is currently supported by Firefox, Opera and Safari to create the appearance of inset text. Inset text being text that has been pushed into the background, almost like a reverse embossed effect.

The Effect We Are Going To Create

If you look at this image and text treatment you will see what we are trying to achieve. Through color and slight shading it creates the appearance that the text has been pushed inward into the background. Previously we would have had to create this effect in an image, however now we can do it simply by using the text-shadow property (despite its primary use being designed for creating a relief effect).

Step 1. Primary Text Color

The first step is to make the text we are working with a darker shade of the the background that it will be sitting on. This will make it look further away to users and shadowed from the light, how dark it should be will depend on the colors you are using. I recommend mocking up your text in photoshop to get the right shade and tone.

Step 2. Ridge Color

To really get the inset 3D effect we need to have a thin line of shading around our text to create the illusion of a ridge. By having it below the text where it normally will be a shadow, it will create the illusion of depth. The color should be lighter shade of the background, but not too much lighter. This is another situation where picking the right color is critical, if it is too light it looks strange and if it is too dark you won't be able to see it. You may want to use photoshop to try mockup up the text in order to pick the right color.

Step 3. The Code


     .inset-text {
          font-size: 32px;
          color: #344251;
          text-shadow: 1px 1px 0px #bad3ed;
          font-weight: bold;
     }

The code is very simple, we are just using the text-shadow property to put a 1 pixel line on the text 1 pixel below it, and 1 pixel to the right.

The Result

Here is an example of the result. If a user doesn't have a browser that supports the text-shadow property they still see and can read the text with no issues!

Here Is Some Inset Text

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



Talk of the town
  • South West Balloon Flights: Thanks for the script. Looks nice.
  • Tony: How about WP Super Cache. Google now takes into account a site’s loading time and what better way to...
  • Emek Elektrik: Thanks Adminstrator For Dar Gelirli Users…
  • Nelly: That is a good article for css thank you admin
  • Nelly: I want to learn css Can anyone help me? Thanks a lot
Amigos

What do you think?





14 Responses so far

By Altinkum
on December 15, 2009

thanks, this is interesting and very usefull

By Neelakandan
on November 21, 2009

Thank you very much for this one. It’s very helpful… :)

By professional website Templates
on November 18, 2009

Thanks nice blog … learned some good tips of css3

By webdesigner freelance
on November 8, 2009

Thank you again for this article very useful.

By 99sousuo
on November 8, 2009

好文章

By ezel
on November 2, 2009

backing up data- that’s the one thing I often overlook, procrastinate, because it’s always such a tedious task.

By 减肥方法网
on November 1, 2009

蛮好的

By Mike
on October 27, 2009

Sounds like a good effect, unfortunately I can’t see the effect in my browser. Which versions of browsers currently support CSS3?

By Wes Bos
on October 22, 2009

Great Tutorial, I really like this look and I’ll take a CSS solution over SIFR

By Swank City
on October 22, 2009

We’re using this on a few of our H tags… I think you’ll see a lot of over-use in 2010 though.

  1. Nov 10, 2009: Texto em relevo usando text-shadow do CSS3 - André D. Molin » Blog – PHP, MySQL, xHTML, CSS, Tableless, jQuery
  2. Nov 10, 2009: Больше, больше эффектов c CSS3! | rotorweb.ru | Проблемы и решения в Web-дизайне
  3. Nov 9, 2009: Inset Text com CSS3 » CSS no Lanche
  4. Nov 1, 2009: Twitter Link Roundup (10.25 – 10.31)