Graphic headlines while maintaining semanically correct markup
My clients and the Art Director that I work with often wants graphic headlines set in a specific font. I agree since fonts are often important carriers of corporate and brand identities and the combination of Umbraco and ImageGen provides me with the tools to deliver this easily. On the other hand I take pride in making sure that the websites that I create generate semantically correct markup. A great deal of my clients even demand this and on a personal level it's a question of democracy. Not all people can read what is graphically printed on a screen unless it's accompanied by a computer-readable text. On top of that you have to please the search engines. They can't read a GIF-headline(!)
In short: I want the H1-tag to represent the page main headline, the H2-tag the level 2 sub headline and so on, but I want them to look good for all us "de luxe viewers" with a special sassy font, and all that.
Luckily there are ways to get the best of both worlds, using some tricks in CSS. Here's an example of a headline (using ImageGen to generate the graphic headline) that will display a graphic image if you have stylesheets turned on and an ordinary H1 tag if you have turned off all stylesheets in your browser:
<h1 class="myGraphicHeadlineStyle" style="background:url('/umbraco/ImageGen.aspx?text=HEADLINE&FontSize=40
&Font=/fonts/MySpecialFont.ttf&FontColor=226644&Align=left&
Valign=top&Width=500&Height=60&AntiAlias=True');width:500px;height: 60px;" title="HEADLINE">HEADLINE</h1>
Accompanying this tag there is a CSS class: myGraphicHeadlineStyle. It looks like this:
.myGraphicHeadlineStyle
{
background-repeat: no-repeat;
overflow: hidden;
text-indent: -100em;
/* top right bottom left */
margin: -20px 0px 0px -10px;
}
The key things to look at here is overflow and text-indent. What happens is that there is always an HTML headline printed but the fact that overflow has been set to hidden and that the text is indented to -100em will make the browser render the HTML-version of the headline out of sight for the user, unless all stylesheets are turned off.
Looking closely at the code you'll see that the image headline is a background image to the H1-tag, introduced using CSS. Thus no CSS = no graphic headline, no indent and no overflow hidden. This means that if you turn off all stylesheets you'll see a regular times H1 headline that is as semantically correct as agent Dale Coopers suit.
To be honest: I'm not going through all this trouble to please the minority of users who prefers to surf the web bereft of all the visual elements that CSS's introduce. The main purpose is to present a semantically correct face to search engines like Google. To a search engine an IMG-tag is an image, an H1-tag is a headline and never shall the two meet.
This is all experimental and has been pieced together using various sources on the net so please send me feedback if you discover something wrong in my logic.
. Put it in the folder where all the other flags are.