Home arrow Style Sheets arrow Page 3 - Spanning H2 Elements for Image Replacement
STYLE SHEETS

Spanning H2 Elements for Image Replacement


Welcome to the fifth part of a six-part series on CSS-based image replacement techniques. In this part, you'll learn how to use Todd Fahrner’s image replacement method with all of the H2 elements of a basic web page.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
November 30, 2009
TABLE OF CONTENTS:
  1. · Spanning H2 Elements for Image Replacement
  2. · Review: applying Fahrner’s IR method to the H1 header of a web page
  3. · Styling multiple H2 headers with Fahrner's IR method
  4. · The finished version of the sample web document

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Spanning H2 Elements for Image Replacement - Styling multiple H2 headers with Fahrner's IR method
(Page 3 of 4 )

As you may have guessed, implementing Fahrner’s IR approach with all of the H2 elements of a web page is only a matter of adding a couple of extra <span> tags to them and applying the same CSS styles used in the example learned in the previous section. It’s that easy, really.

However, the best way to understand the fine details of this process is by showing some functional code. So, below you'll find the CSS block that performs the corresponding image replacement on all of the H2 elements included in the web page:

 

 

h2 {

width: 300px;

height: 150px;

margin: 0;

padding: 0;

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

}

h2 span {

display: none;

}

From the above code fragment, it’s fairly easy to realize how the replacement process is accomplished on all of the H2 headers. Once the following background image is assigned to each of the headers:

Then, each portion of text surrounded by the extra <span> tags is hidden from view via the “display: none” style. That’s not difficult to grasp, right?

So far, everything looks good, and you should now have a clear idea of how to apply Fahrner’s IR approach to multiple H2 elements in one go. Yet, the previous example is still incomplete, as it’s necessary to bind it to the corresponding markup of the web page.

But guess what? This will be done in the following segment. Therefore, go ahead and read the lines to come.


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