Subtle CSS3 Typography that you’d Swear was Made in Photoshop
videos

Subtle CSS3 Typography that you’d Swear was Made in Photoshop

Tutorial Details
  • Topics Covered: CSS3
  • Difficulty: Moderate
  • Tut Format: 13 Minute Video
Download Source Files

Final Product What You'll Be Creating

This entry is part 8 of 16 in the CSS3 Mastery Session
« PreviousNext »

Thanks to text shadows, outlines, transitions, and even text gradients, we can now create cool typography that you’d swear had to be made with a program like Photoshop. Nope, all CSS3 baby! Let’s take a look in this video quick tip.

<!DOCTYPE html>

<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Subtle Typography</title>

	<style>
	body {
		background: #666;
		padding: 1em;
	}

	h1 {
		position: relative;
		font-size: 200px;
		margin-top: 0;
		font-family: 'Myriad-Pro', 'Myriad', helvetica, arial, sans-serif;
		text-shadow: 2px 3px 3px #292929;
		letter-spacing: -7px;
		-webkit-text-stroke: 1px white;

	}

	h1 a {
		text-decoration: none;
		color: #ffffff;
		position: absolute;

		-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), color-stop(50%, rgba(0,0,0,0)), to(rgba(0,0,0,1)));
		text-shadow: 0 2px 0 #e9e9e9;
		-webkit-transition: all .3s;
		-moz-transition: all .3s;
		transition: all .3s;
	}

	h1 a:hover {
		color: #185a50;
	}

	h1:after {
		color: #dbdbdb;
		content : attr(data-title);
	}

	</style>
</head>
<body>
     <h1 data-title="Hello Readers"> <a href="#"> Hello Readers </a> </h1>
</body>
</html>

Add Comment

Discussion 115 Comments

Comment Page 1 of 21 2
  1. Christophor S. Wilson says:

    This is great!!!

  2. Filipe Carrano Pacheco says:

    Amazing indeed.

  3. Jeff Adams says:

    This is GREAT thanks alot.

    I’m finding that I’m using Photoshop less and less these days, it used to be all about the dropshadows and pixel perfect texts – but now with CSS3 it’s alot easier, plus something like Cufon reallyh helps.

    My next Themeforest theme is going to be loaded with features like this :P

  4. Matt says:

    Kind of pointless as half of the techniques used are only supported in ‘some’ browsers. Still, nice tut.

  5. Really looks like in PS. Thanks for tut.

  6. Jonessie says:

    OMG :)

    Another great Tutorial from Jeff. If somebody showed me this and said it was created using PS I would have bet money on it. Awesome and one to be added to my favs.

  7. I’m weary of the content being in the :after — this I think is the second Tut I’ve seen that does something like this, and I personally find it kind of disturbing. Not only does this not seem like the intention of :after… but it just creates all kinds of weirdness for dynamic content on sites.

    Seems like that one aspect of it might be better to make as a JS based progressive enhancement.

    Other than that, pretty nice.

    • On one additional note, I suppose this might not matter with something like HTML5 as you could use the attr() for the after content and presumably have a custom data- attribute that repeats the text. This would resolve having the static content in the CSS.

    • w1sh says:

      I see your point, but if I’m not particularly concerned about what screen readers or search engines read, then adding that little :after tag makes this deal. The rest is pretty basic stuff, but that anchor:after trick with a shadow of it’s own is what makes it pop off the page.

      • It has nothing to do with screen readers and search engines… it has to do with code separation and where content belongs. The whole point of CSS is to separate your style from your content, the minute you start adding static content into CSS that flies out the window. Using the content: attr(data-whatever) would resolve this by allowing you to add a data-shadowtext=”" attribute or something of that nature, but until then, who wants a constant string stuck in their CSS with a header?

        What happens when you’re header is in a database is gets dynamically included in the page? Now you need to run your CSS through your back end scripting language to place the same dynamic content? It breaks the whole model.

    • Jeffrey Way says:
      Author

      Hey Matthew –

      Good points. A couple quick notes:

      1) You’re right. But more than disturbing, it’s the only way I know to create text gradients *right now*. These types of quick tips are more about the “how to do it if you wanted to,” than for every day usage.

      2) I hard coded the content into the :after to save time, but have just now updated the code above to make things a bit more separated and dynamic.

      Thanks for your thoughts! :)

      • Devon Govett says:

        Hey Jeffrey,

        There is another way to create text gradients, however it only works in webkit based browsers right now.

        If you set the color of the text to transparent, the background to a -webkit-gradient, and add the -webkit-background-clip: text property to it, you can get any gradient you desire. For example:

        h1 {
        color: transparent;
        background: -webkit-gradient(linear, left top, left bottom, from(red), to(orange));
        -webkit-background-clip: text;
        }

        Granted, it doesn’t yet work in any other browsers, but hopefully it will work there soon.

        Cheers!
        Devon

  8. Daniel says:

    This looks really great! I really like those CSS tips!
    Thank you!

  9. piyanistll says:

    perfect thanks for sharing

  10. Artjunks says:

    Yea…
    nice PS-Style…

    looking good :D

  11. Jeroen says:

    Don’t want to get all bitchy on you Jeffrey, but probably on your screencast the Myriad font is not installed and it switches back to Helvetica later defined in the Font stack, should probably change that I guess or make a note ;)

  12. w1sh says:

    Love this one. Beautiful effect. Going to test it in FF/IE right now and see if I can come up with a really nice version.

  13. Very nice effect. I really like subtle design things like this, enhances everything nicely.

  14. Aravind says:

    Nice work….

  15. A progressive era for Web Dev, nice, very nice post.

  16. Jason says:

    But does it work in IE6? *ducks* Sorry, had to, move along.

  17. Murillo says:

    Good Job!

    Jeef, can you show us something using the html5 boilerplate?

    Thx!

  18. Nice; good example of transitions… great stuff

  19. Christopher says:

    I often forget you can play with tracking in css with the letterspacing property. It does so much to improve web typography. Excellent tut.

  20. m4niac says:

    is it cross-browser? or, to be more specific… do all browsers are now CSS3-ready? :)

  21. Liam says:

    I find it ironic how the example text at the top is an image rather then actual html text.

  22. So … I can now start doing a web version of photoshop for html ? :)

  23. kab00m says:

    TNX for sharing! \m/

  24. Rob Phillips says:

    It looks great, it’s just a shame that it’s pointless to implement as any large scale site which will have to cater to those browsers which we all hate. It’s a tough one.

  25. Soni Budi Wicaksono says:

    zuper fun-tastic! i think typography contributes to create senses of well-formed and captivating graphics design while we designing the web..

  26. Good to see that YouTube’s new 15min time limit is being made use of. Keep up the good work, Jeffrey. Now if only the other browsers would implement these things…

  27. lafncow says:

    Undeniably beautiful, but am I the only one who finds -moz and -webkit just as unacceptable as the proprietary differences MS has built into IE? I’m not knocking this tut, it’s great, but I’m annoyed with Mozilla and Google: more hacking is not progress!

  28. Sahan says:

    PSD vs CSS huh? :)

  29. wparena says:

    CSS really invading the web technology and helping designers and developers and creating ease from hard work of Photoshop

  30. Jaspal Singh says:

    Great tutorial with CSS3 Typography.
    Thanks for sharing.

  31. Ahmed "C.Z" says:

    Hey Jeffrey
    well that’s was a very great tut
    thanks for explaining the rgba
    i have known the rgb but didn’t know what’s the meaning of the a “red green blue and then what is the a for XD” that’s was one of the must useful thing for me in these tut because it was the only thing i didn’t know it :) :)
    i think that CSS3 is the biggest enemy for the future of photoshop web designing “gradient ,shadows ,@font-face ,stroke and mask image” those things well decrease photoshop need in web designing don’t you think so ??

    • Nikolai says:

      I totally agree with you. Will come a time in which designers will use Photoshop just to see the entire pre-design and then there will be almost no slices, except for the pictures :)
      But there is still plenty of time until this happens :)

      and Jeffrey, great article … again :)

  32. prashant says:

    What is wrong with you Jeffrey? Was that really tough and new for CSS3 users? These days you are not doing quality posts and doing some fillers. I am Great fan of envato network and am very upset form such posts. Its better not to write anything. Your blog is known for its quality and not quantity. Please maintain that.

    Thanks
    Prashant

  33. harly says:

    What a nice tutorial CSS3. Great explanations Thanks for the nice stuff.

  34. Jauhari says:

    Wonderful tutorial… CSS3 is the way you design ;)

  35. css3真是非常的神奇
    css3 is a miracle.

  36. Lars Gunther says:

    Its always nice to see new experiments with CSS. The effect is quite cool.

    However there is one thing that would make this demo even more awesome. Firefox 3.6+ does gradients. In fact, it does gradients with a syntax more close to what will become the W3C standard. Perhaps one could apply the -moz-gradient on the text directly, if one does not wish to mess with the SVG masks and filter effects that are new in Firefox 4 and the equivalent of webkit-mask (and some).

    Also, while Im at it, Firefox is getting -moz-font-feature properties that could be used to achieve some cool effects as well: http://hacks.mozilla.org/2009/10/font-control-for-designers/

  37. Luis Lopez G says:

    So in a few words:

    Its like photoshop, you make a big text with a drop shadow, then add a white 1px stroke and put a light-gray to white gradient with 90° but with css! cool I didn’t know that -moz-text-stroke and I think it’s awesome.

    Thanks dude.

  38. SaviourSix says:

    Seems like a really long way to skin the cat, but a very useful tut anyway! Thanks.

  39. BJ says:

    Very nice..

  40. Patrick says:

    …and no word about compatibility. Just only works in Webkit-Browsers. No fallbacks for other browsers.

    Yeah, reeeaaalllyyy nice work.

  41. Huynh Tho says:

    Wonderful! I can’t imagine CSS3 can do such a thing like this

  42. Hassan says:

    You can use multiple text shadows for the 3d effect. Safari/Chrome, Firefox and Opera all support multiple text shadows. I don’t currently have IE9 so don’t know about that.

  43. Dima says:

    Thank you, guys
    I found this information extremely useful for myself

  44. CorvosKK says:

    Absolutely awesome article! I can’t wait till we can start using this in mainstream projects. It won’t be long!

    And I’m sure you’ve been asked this before, but what do you use to record your video tutorials? I have been using Jing lately, but even the pro version will only let you record up to 5 minutes of video.

    Thanks for another cool tutorial

  45. CorvosKK says:

    After reading Devon Govett’s post, I tried the technique out and wanted to mention that while it does work in webkit browsers, as soon as you begin applying other styles, such as text-shadow, it breaks the styling, placing the text-shadow above the text in the z-index.

    Here’s the preview of what it’s doing: http://screencast.com/t/MDNmYWVmZTk

  46. Monit says:

    This is Awesome!

    Many thanks Jeff

    Monit

Comment Page 1 of 21 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.