skip to content

:first-letter pseudo-element BUGS!!

9th January 2007


Information

My recent 'sliding-doors' examples have led me into looking at the :first-letter pseudo-element as a method of holding a second background image using just a the link text.

I thought that I should document my findings for anyone else who wishes to persue this for their own purposes.

The above demonstration shows how the first letter can be styled using the available properties as listed below.

  • font properties
  • color properties 
  • background properties
  • margin properties
  • padding properties
  • border properties
  • text-decoration
  • vertical-align (only if 'float' is 'none')
  • text-transform
  • line-height
  • float
  • clear

I believe that Opera, Netscape and Mozilla get all of these right. Firefox get the padding, background image position and the underline wrong. BUT IE5, IE6 and even IE7 gets this very wrong.

In IE the underscore goes through the letter, the padding and margins are wrong, the vertical-align and :hover are not styled, the background image is wrongly positioned, but worst of all the border widths are wrongly displayed. The widths should increase clockwise around the first-letter, but IE reverses this and the borders increase in an anti-clockwise direction. The color order, however, is correct.

THE GOOD

Opera screenshot

Opera - as I would expect

Safari screenshot

Safari - underline narrow

Mozilla screenshot

Mozilla - negative margins

Netscape screenshot

Netscape - negative margins

Firfox linux screenshot

Firefox linux - padding and height


THE BAD

Firefox screenshot

Firefox - padding, margin, height, background image and underline


and THE UGLY

IE5.01 screenshot

IE 5.01 - no styling

IE5.5 screenshot

IE 5.5 - padding, margins, background image, border-width, narrow underline

IE6 screenshot

IE 6 - padding, margin, border-width, narrow underline, font colors (no :hover)

Opera screenshot

IE 7 - padding, margin, vertical-align, border-width and narrow underline

Copyright

You may use this method on your personal 'non-profit' web site without seeking my permission. A link back to CSSplay is always appreciated.

Commercial usage is also permitted without seeking approval, but I would ask that a donation is considered to support my work on CSSPlay.

If you are having problems integrating any of my demonstrations into your website then I now offer a service to fault find and correct any errors that you may have introduced. Please email me for more information.




Recommended Sites

CSSplay web design/assistance

"The citroen.co.uk web site uses
CSS Play code for the site drop down menus.
This code works seamlessly in IE 6 & 7, and is an excellent solution to the Creative requirements of the site."

Damon Clark - Brandwidth


Advertise with CSSplay

CSS play pages



CSS play recommend

SitegrinderSocial Media Applications On DemandPSD to HTMLFree, practical CSS menus, layouts, and examplesQuality UK Web Hosting