Style Sheets
  Home arrow Style Sheets arrow Using Span Tags for Image Replacement
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

Using Span Tags for Image Replacement
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2009-11-25

    Table of Contents:
  • Using Span Tags for Image Replacement
  • Review: Mike Rundle's image replacement method
  • Working with non-empty span tags
  • Combining the CSS and the structural markup

  • 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


    Using Span Tags for Image Replacement


    (Page 1 of 4 )

    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.

    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!

    More Style Sheets Articles
    More By Alejandro Gervasio


       · This fourth part of the series explores the image replacement method created by Todd...
     

    STYLE SHEETS ARTICLES

    - Creating Framed Pictures with CSS
    - Using a CSS Shading Effect to Decorate Images
    - Decorating Images with CSS
    - Finishing a Drop-Down Menu with the Hover CS...
    - Creating a Drop-Down Menu with the Hover CSS...
    - Building CSS-based Tooltips with the Hover P...
    - Rediscover the Hover CSS Pseudo-Class
    - Langridge`s Image Replaceement Technique: A ...
    - Using the Padding-Top CSS Property with H2 H...
    - Using the Padding-Top CSS Property for Image...
    - Using Fahrner`s Improved Image Replacement M...
    - Using Empty Span Tags with H2 Headers for Im...
    - Image Replacement with Empty Span Tags
    - Wrapping Hyperlinks with Span Tags for Image...
    - Spanning H2 Elements for Image Replacement







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