Home arrow Style Sheets arrow Image Replacement with Empty Span Tags
STYLE SHEETS

Image Replacement with Empty Span Tags


In this seventh part of a series that explains image replacement techniques, I show you how to use the enhanced version of Todd Fahrner’s method. It uses two empty <span> elements to perform the image replacement process, thus efficiently addressing the problem that arises when the background image assigned to the targeted web page element isn’t downloaded properly by the browser.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
December 02, 2009
TABLE OF CONTENTS:
  1. · Image Replacement with Empty Span Tags
  2. · Review: applying Fahrner's approach to hyperlinks
  3. · Improving on Fahrner with empty span tags
  4. · Fahrner's improved method in action

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Image Replacement with Empty Span Tags
(Page 1 of 4 )

Regardless of its intimidating name, image replacement is nothing but a simple method that uses the functionality of CSS to add an appealing background image to a web page element, while hiding its inner text from view.

Frankly speaking, image replacement (IR) is a fairly old player in the terrain of professional web design. As such, it comes in different flavors and versions, so it’s quite probable that among the plethora of options available today, you'll find the one that best suits your needs.

However, when it comes down to implementing IR approaches that rely only on style sheets to do their business, usually they belong to one of two well-differentiated categories: first, the methods that do require coding additional markup, generally in the form of <span> tags, and second, the ones that don’t. In this case, fortunately, there’s not a gray, undefined area.

In previous parts of this series I demonstrated how to implement the image replacement approach developed by Mike Rundle. It doesn’t demand the use of extra markup, and utilizes the “text-indent” CSS property for hiding the text of a targeted element. In addition, I provided an in-depth coverage of Todd Fahrner’s method, which does employ a couple of <span> tags to achieve exactly the same result.

For obvious reasons, if these two methods do the same thing, then it’d be logical to choose the first one, as this doesn’t use additional <span> elements, right? Well, as you’ll recall, in both approaches, if the element’s background image fails to download, it will remain hidden from display and therefore inaccessible.

However, there’s an improved version of Fahrner’s approach that permits us to solve this issue fairly easily. In the following lines I’ll be showing how to implement it with the H1 header of a basic web page. To learn more about this enhanced IR approach, start reading right now!


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 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials