Home arrow Style Sheets arrow Page 3 - Wrapping Hyperlinks with Span Tags for Image Replacement
STYLE SHEETS

Wrapping Hyperlinks with Span Tags for Image Replacement


In this sixth part of a multi-part series on CSS-based image replacement techniques, I demonstrate, with some easy-to-follow code samples, how to apply Fahrner’s image replacement technique to a group of web page links to make them look slightly more appealing.

Author Info:
By: Alejandro Gervasio
Rating: 3 stars3 stars3 stars3 stars3 stars / 2
December 01, 2009
TABLE OF CONTENTS:
  1. · Wrapping Hyperlinks with Span Tags for Image Replacement
  2. · Review: using Fahrner's image replacement method with H2 elements
  3. · Styling some hyperlinks
  4. · Binding the CSS block to a simple XHTML document

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Wrapping Hyperlinks with Span Tags for Image Replacement - Styling some hyperlinks
(Page 3 of 4 )

Frankly speaking, applying the image replacement method that you learned in the previous segment to a few web page links is a process that doesn't different too much from styling HTML headers. In this particular case, the method will be implemented only with <a> elements that have been assigned a "fancy_link" CSS class, but as you may guess, it's possible to use the method with all of the links included in a web document.

Having said that, please focus your attention on the following CSS styles, which perform the aforementioned image replacement process in a snap:

.fancy_link {

display: block;

width: 200px;

height: 50px;

margin: 0;

padding: 0;

background: url(fancy_link.png) top left no-repeat;

}

.fancy_link span {

display: none;

}

Definitely, that was easy to code and read, wasn't it? As shown before, by adding a couple of <span> tags to all of the <a> elements with the CSS class "fancy_link" will make them appear on screen decorated with the following background image:

Of course, if the web page contains many links that need to be styled in this manner, the process can be pretty annoying, considering that each link must include extra markup that has no true semantic meaning. However, if you find that this method suits your requirements, then you'll have to learn to live in harmony with that issue.

Having shown the set of CSS styles that implements Fahrner's approach, now it's time to tie them to the corresponding structural markup, so you can see how they can be put to work together. Therefore, in the last section of this tutorial I'll be coding another sample web page that will show the final result of this image replacement process.

Now, click on the link below and keep reading.


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