Home arrow Style Sheets arrow Using Span Tags for Image Replacement
STYLE SHEETS

Using Span Tags for Image Replacement


In this fourth part of a six-part series on image replacement, I explore a CSS-based image replacement method originally created by Todd Fahrner. It bases its functionality on using a couple of extra <span> tags to hide the text wrapped by a targeted web page element, while keeping its background image visible.

Author Info:
By: Alejandro Gervasio
Rating: 4 stars4 stars4 stars4 stars4 stars / 3
November 25, 2009
TABLE OF CONTENTS:
  1. · Using Span Tags for Image Replacement
  2. · Review: Mike Rundle's image replacement method
  3. · Working with non-empty span tags
  4. · Combining the CSS and the structural markup

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using Span Tags for Image Replacement
(Page 1 of 4 )

In the last few years, different image replacement approaches have become popular in response to web designers' need to embed appealing background graphics into different web page elements -- without messing up the structural markup with tags that have no actual semantic meaning.

True to form, most of these approaches rely on the functionality of CSS to achieve the replacement process, although it's also fair to say that there exist some other methods that make use of Flash and JavaScript to produce similar results. This group of articles explores only the ones that utilize style sheets, as they offer a flatter learning curve and fewer accessibility issues.

Of course, if you've already read the tutorials that precede this one, then you have a clear idea of how to use the image replacement method created by Mike Rundle. In those tutorials I explained how to add some fancy background images to H1, H2 and <a> elements of a basic web page, without changing a single piece of the page's markup.

In simple terms, this method does its "magic" simply by assigning a huge negative value to the "text-indent" property of the element being styled, a process that hides its inner text, while revealing the corresponding background image.

As you may have guessed, though, apart from Mike Rundle's, there are a few other IR approaches that I plan to cover in this and subsequent installments of the series. With that goal in mind, in the lines to come I'll be explaining how to implement the method developed by Todd Fahrner, which uses a couple of <span> tags to hide the text wrapped by a given HTML element.

Now, let's leave the theory behind and start exploring the inner workings of Fahrner's image replacement method. Let's jump in!


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials