The paranoia about ‘extra markup’ for things like image replacement is something I kick to the curb – funny since I’m rabidly anti-wasteful markup… but it really seems like people are putting their efforts in that regard in all the wrong places… repeatedly I see people going “I don’t want to use an extra span” when the pages they make have 20 or 30 pointless DIV, classes and ID’s, hundreds of K of javascript for nothing, multiple embedded fonts, IE conditional crap on a layout that shouldn’t need it, javascript doing CSS’ job, static scripting in the markup and all sorts of other nonsense. All things in their place people!
Adding an empty tag remains the most reliable of techniques which is why a gilder-levin-esque approaches are what I use. Oh noes, I might have to spend ten characters on a SPAN…
Usually bandwidth savings can be better found elsewhere… much like FIELDSET, LEGEND, or building content-first dynamic width column layouts suck it up and use the extra element!
So far as other methods go, ANY technique that doesn’t work when you turn images off…
COMPLETELY DEFEATS THE POINT OF USING IMAGE REPLACEMENT IN THE FIRST PLACE!
:kaioken: :kaioken: :kaioken: :kaioken: :kaioken: :kaioken: :kaioken:
Which is why the monstrous negative text-indent, font-size:1px or the display:none span are total garbage and a WASTE not only of code but also of your time and potentially the visitors. At that point you might as well just put a IMG tag in the markup! (and as someone who does browse from a android tablet with images turned off to save $$$ on my data plan)
I also tend to put the span AFTER the content
<h1>Site Title<span></span></h1>
Because I can use the same structure not just for image replacement, but for sliding doors, inline-block endcaps, and a whole host of other effects making future reskinning easier. Means you have to state the position in the CSS, but I’ll often do that anyways for other effects or making the image larger or smaller than the h1 element itself.
The only ‘problem’ with gilder-levin is that if you use gecko’s sweetly retarded crack addict “resize PX fonts but nothing else declared in PX” method of zooming (which THANKFULLY is no longer the default) your text could peek out from under the image… OH WELL… Anyone who cares about zooming or accessibility probably isn’t using Nyetscapes sweetly retarded cousins ANYWAYS since it’s a miserable /FAIL/ across the board at that anyhow. Oh noes, it breaks in a browser zoom mode that’s broken/useless on 99% of websites ANYWAYS – NOT THAT?!?