Style Sheets
  Home arrow Style Sheets arrow Page 3 - Indenting H2 Elements as a CSS Image Repla...
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

Indenting H2 Elements as a CSS Image Replacement Technique
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-11-23

    Table of Contents:
  • Indenting H2 Elements as a CSS Image Replacement Technique
  • Review: image replacement with an H1 header
  • Styling H2 elements
  • Applying the same IR technique to H1 and H2 elements

  • 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


    Indenting H2 Elements as a CSS Image Replacement Technique - Styling H2 elements


    (Page 3 of 4 )

    If you found it easy to understand how to implement the previous image replacement approach with an H1 element on a web page, then when I show you how to perform the same task with all of its H2 headers, your love for CSS will be even stronger, trust me.

    Does this sound a bit exaggerated? Well, it’s possible. Imagine that you’re bored with your text-based H2 elements and want to spice them up with the following background image:

    By using the IR approach that you learned in the preceding section, styling all of the H2 headers of the web document would be reduced to coding the CSS styles below:

    h2 {

    width: 300px;

    height: 150px;

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

    text-indent: -9999px;

    }

    There you have it. Once again, assigning a value of –9999px to the headers in question will make them display the previous background image, while the inner text will disappear into limbo.

    Of course, if you’re like me, you’ll want to see how this short CSS fragment can be merged with the one that styles H1 elements. In the section to come I’ll be showing the full source code of a brand new web document, which will include this last IR snippet.

    Please read the following segment. It’s only one click away.

    More Style Sheets Articles
    More By Alejandro Gervasio


       · This second article of the series shows how to use the image replacement method...
     

    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 7 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek