Style Sheets
  Home arrow Style Sheets arrow Image Replacement with Empty Span Tags
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Image Replacement with Empty Span Tags
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-12-02

    Table of Contents:
  • Image Replacement with Empty Span Tags
  • Review: applying Fahrner's approach to hyperlinks
  • Improving on Fahrner with empty span tags
  • Fahrner's improved method in action

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Image Replacement with Empty Span Tags


    (Page 1 of 4 )

    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.

    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!

    More Style Sheets Articles
    More By Alejandro Gervasio


       · This installment of the series shows you how to use the enhanced version of Todd...
     

    STYLE SHEETS ARTICLES

    - Building Rounded Corners with CSS3`s -webkit...
    - Using the Custom -moz-border-radius Property...
    - Using CSS3`s Border-Radius Property to Build...
    - Adding Semantic Meaning to Styled Code Block...
    - Styling Code blocks with CSS: Using pre HTML...
    - Building Rounded Corners with CSS3
    - Finishing a Casual Navigation Bar with CSS S...
    - Defining a Navigation Bar`s Hover State with...
    - Styling a Blog`s Links Bar with CSS Sprites
    - Creating an Artistic Blog Header with CSS Sp...
    - Defining the Active State of Menu Sections f...
    - Styling the Hover State of a CSS Sprite-Base...
    - Building CSS Sprite-Based Navigation Bars
    - Creating Framed Pictures with CSS
    - Using a CSS Shading Effect to Decorate Images







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek