Method Arts - A Consortium


CSS and Typography

By Brian Warren // Dec 11, 2006 // Code // 38 Comments // Permalink Brian Warren's Mug Shot

image

Barcamp Albuquerque was just a short month ago. I had a great time and enjoyed meeting everyone there. One fascinating thing about Barcamp is that the requirement to present brings out some fun stuff in people. The topics people choose to present come from one of two sources: Either a) It’s what they’re absolutely most passionate about, and thus at least an ad-hoc expert. Or b) It’s whatever issue they recently struggled with, figured out, and need to share with other people to save them the time. I suppose my topic was a bit of both.

I presented on CSS and Typography. My background is in print, and one of my passions as a print designer is typography. I love seeing well-set type printed on a page, I love that at the end of every Harry Potter book they mention it was printed in Garamond. Moving to web was a struggle for me in the type arena. Discovering CSS was wonderful, but immediately the limitations of the web presented themselves and frustrated me.

Once I discovered Flash I was giddy. Just the idea of being able to embed fonts in a site got me rushing off to tell my friends about it. Naturally, as many web designers did, I discovered some of the limitations of publishing websites with flash and I ran back to CSS and tried my best to make websites with the limited web-safe fonts, and felt a little bit of my typographic soul die.

Not all is lost though; in my presentation at Barcamp I talked about two techniques you can use to incorporate some custom typography, at least in headlines, on your website.

Image Replacement

The first is image replacement. I’ve heard a few people refer to this idea as “dead” or at least “a bad idea”. However, I submit that, if used judiciously, image replacement can do feats no other technique can manage.

Let’s start with how how to use it. Here’s a perfectly obvious headline:

<h1>Method Arts Fall Badminton Spectacular</h1>

Instead of using text, we want to use something fabulously designed, so in the CSS, you give the text a negative indent, and then put in a background image behind the h1 element.

h1 {
margin:0;
text-indent:-32697px;
background: url(graphics/head.jpg) no-repeat 0 0 ;
width:508px;
height:173px;
}

Poof! The image is there, but the HTML remains having text in an h1 tag. (Why the odd number for text-indent? That’s Opera’s maximum value that it will understand for text-indent. Thanks to Steven in the comments for alerting me to the problem.)

I’m not dead yet

Why is this better than just using an image tag? I agree it does seem like using image replacement is a lot of work. There are a few reasons that this is worth it.  For one, what Google sees when it comes to the site is some text in an H1 tag, rather than an alt tag. Google may or may not interpret that alt tag to be an important headline. Next, when you print that page, instead of printing a graphic that wastes ink and is blurry anyway because it’s at screen resolution, you print text. This requires a bit of extra work in that you need to use print style sheets, but it’s work you should be doing anyway.

Image replacement isn’t a silver bullet. The main limitation is that it only works for static headlines and areas. To jump that hurdle designers need to employ something more sophisticated.

sIFR

sIFR is a pretty clever little tool that uses flash and javascript to dynamically replace any text in the page with the font of your choice. I know, it sounds too good to be true, but it works. sIFR also accomplishes the daring feat of being both completely valid and accessible. Going through code examples here will be too tricky, so I’m going to link to my code from the presentation. You can also read up on sifr here.

sIFR, too, has its drawbacks. It’s trickier to implement, it’s more work and it uses javascript. Still, the payoff is that you get to use your custom fonts in dynamic headlines. That’s hard to beat.

Soup Up Your Toolbox

All in all these are great tools to have in your toolbox when making websites. We use both of them right here on the Method Arts website. One of the most fun uses of them is on the party invite that we did. Sure, it looks just like a bunch of images, but it’s actually replaced text. It seemed like a silly geeky thing to do, but it actually worked. Google indexed the page, and people were finding the invite based on search terms in the replaced text.

Neither tool is a silver bullet, but these days it doesn’t seem like one exists. Nonetheless these are essential tools to have in your toolbox for getting great typography on the web.

Downloads

Podcast of my presentation (with interview) (thanks to Reid Givens from ALR Marketing for podcasting the entire event).
PDF Presentation
Code Examples

  • Hey, just wanted to say, this was a kickass presentation.

    Giles Bowkett - had this incredible stroke of brilliance on Dec 27, 2006

  • Thanks Giles! It was good to meet you down there. Your presentation was great though totally over my head. I felt like a total wimp.

    Brian Warren - made this noise on Jan 1, 2007

  • I believe that Opera has a problem with 5 digit negative text-indent.

    It is better to stick with -9999px.

    Good article by the way and I haven't checked up on sIFR for a while now.

    Steven Hambleton - added to the collective on Jan 1, 2007

  • Why not including a span in the h1, and then apply display: none at the span object?

    I always thought the -values is a bit messy.

    smile

    / Martin

    Marteinn - added to the collective on Mar 8, 2007

  • Hopefully you guys can teach these guys some tricks:

    http://www.subdreamer.com/plugins/p13_download_manager/images/176.jpg
    http://www.subdreamer.com/forum/showthread.php?t=9381

    Someone recognized your site's awesomeness and is selling it confused

    Johan Wilkes - started this rumor on Mar 17, 2007

  • Martin, i believe the reason to use negative values instead of display:none is because of screen readers. Most screen readers read the css. So if it's display:none then the blind have no access to that tag. With the negative value i believe it can still read it.

    Justin Sepulveda - had this incredible stroke of brilliance on Apr 16, 2007

  • An alternative method to the CSS Heading you created is to use this markup

    <H1><span></span>Some Text</H1>
    h1 {
    position: relative;
    font-size: 2em;
    height: 88px;
    width: 155px;
    overflow:hidden;
    }
    h1 span {
    background-image: logo.gif;
    height: 88px;
    width: 155px;
    position: absolute;
    left: 0px;
    top: 0px;
    }


    Give the heading a fixed size (ems of course) and then absolutely place the span over it and give the span a background image.

    This way you achieve 3 things:
    1. Screen Readers can Read it
    2. You get your Image logo
    3. People with images disabled can still read your logo.

    - had this incredible stroke of brilliance on Apr 21, 2007

  • yes very nice tut. but some of those things wont work if you use IE6 in specific cases when you have under float and absolute positions. i hope very soon Microsoft pushes everyone into IE7 cause there everything is fixed

    Victor - started this rumor on Jul 1, 2007

  • There are many types of credit cards and it’s very important to understand which one is the right one for you. It is easier to do that when you can compare all the offers by rates, fees and rewards. I usually check

    <a href= http://deliquent-creadt.cn/credit-score-fica-576.html >fica credit score 576</a>

    unsecured visa - came up with this gem on Jan 3, 2008

  • There should be added overflow:hidden to CSS definition of Brian's example, if that header is a link. Otherwise when clicked Firefox will show it's default link dotted border for 32697px

    - shared this intimate secret on Feb 17, 2008

  • You should be cautious of hiding text. The Google Webmaster Guidelines [http://www.google.com/support/webmasters/bin/answer.py?answer=66353] specifically state:

    "Hiding text or links in your content can cause your site to be perceived as untrustworthy since it presents information to search engines differently than to visitors."

    Joshua McGinnis - added to the collective on Feb 22, 2008

  • Don't wory about it I do it all the time and it works great with google. BTW see construction of main navi on [http://www.zeldman.com], and it works great there too.

    - used their words like weapons on Feb 25, 2008

  • Thanks for the link for SIFR, appreciate it

    Celebrity Foods - started this rumor on Feb 26, 2008

  • Hi!
    I think you have a lovely website

    wer t
    w




    wert


    wert


    53 45t3t34/3456#$%^#
    12341

    12341 243 3


    kent8

    John - used their words like weapons on Mar 20, 2008

  • Thanks for this I have learn't a lot of CSS cus I started making lots of myspace pages

    All In One Forum

    ALL IN ONE FORUM - started this rumor on Mar 24, 2008

  • That was a really nice CSS lecture.

    Thanks a lot, I just learned a few new tricks. smile

    Tim

    Tim - came up with this gem on Mar 26, 2008

  • I've studey css - but please tell me why YOU guys use css for menu navigation. Flash more flexible wink

    flash kit - couldn’t keep them to themselves on on Apr 11, 2008

  • Aaaanndd CSS seems to be ... ???

    Owen W Brown - shared this intimate secret on Apr 27, 2008

  • Guys, what is ONLINE?

    Mary T Mckinney - typed this brilliance on May 1, 2008

  • That's great,I use CSS to desing and feel free

    haiming webhosting reviews - shared this intimate secret on May 9, 2008

  • I've ues a lot of CSS tools.But still like you article!

    haiming webhosting reviews - had this incredible stroke of brilliance on May 16, 2008

  • I remember when Firefox enter in browser market and i looked at my company website, results was terrible, header was my footer :-@, After i discover power of CSS, it is part of my life.

    Canvas Prints - came up with this gem on May 22, 2008

  • Thanks very much.I now have a nice CSS editor:-)

    Chinese SEO Services - used their words like weapons on May 22, 2008

  • Aaaanndd KLSD seems to be ... ???

    Tammy R Limon - had this incredible stroke of brilliance on May 27, 2008

  • Great article!!! very usefull. CSS is always powerful and it is portable too. Can achive so many things with CSS itself.

    Preethi - couldn’t keep them to themselves on on May 29, 2008

  • Very useful articles and comment also. CSS makes design sharp and easy to maintain.

    I must say hidden content and links both are bad tricks, Google will through your site once it found.

    Web Design Company Los Angeles - came up with this gem on Jun 5, 2008

  • "Poof! The image is there, but the HTML remains having text in an h1 tag." - I won´t recommend this as it is against the Google Guidelines. Maybe it workes at the moment or worked in the past but i wouldn´t play with the fire here. One algo update and your site may be penalized.

    Tobi Neuwagen - made this noise on Jun 7, 2008

  • realy intersting post thank you for it.

    שיר בהפתעה - typed this brilliance on Jun 12, 2008

  • tnx for ths tips there.

    ספא - added to the collective on Jun 12, 2008

  • great post thanks a lot my freind.

    איסיקיו - made this noise on Jun 12, 2008

  • Greate work! Thanks a lot Mark!

    Good Funny Jokes - felt the overwhelming need to share this with everyone on Jun 13, 2008

  • very nice

    swim - typed this brilliance on Jun 14, 2008

  • hi , very nice post

    cars - shared this intimate secret on Jun 14, 2008

  • Very useful article! Thanks for sharing...

    SEO Company India - shared this intimate secret on Jun 17, 2008

  • Very interesting. Thanks.

    divx full movies download - used their words like weapons on Jun 22, 2008

  • greapt post

    עיצובים להורדה בחינם - typed this brilliance on Jun 29, 2008

  • wow very good!

    אנציקלופדיה - used their words like weapons on Jun 29, 2008

  • Wonderful articles..Gave a lot of insight on a tough topic..!

    Muscle Gain Truth Review - felt the overwhelming need to share this with everyone on Jul 1, 2008

Rules of Engagement

  • 1. Please leave a comment, not a novel.
  • 2. Don't be a jerk.
  • 3. We might disagree with you. That's okay. It happens sometimes. No need to make this comment area your personal battleground for your point of view. We'll do our best to let you have your say, but 50 comments arguing your opinion is a bit much, eh? We would consider it an abuse of Rule Number 2.
  • 4. Be relevant. You can contact us if you want to say something not pertaining to this entry.

Add a Comment

Name
URL
Email
Comment
Remember my personal information
Notify me of follow-up comments?
Site We Like
Design Observer