28 June 2012

The bgcolor Attribute Doesn't Work in Internet Explorer

There is a bug that impacts all versions of Internet Explorer.  These are the conditions that must exist in order for the problem to occur:
  1. An HTML element must be using the deprecated bgcolor attribute.  This will likely be a table, tr, or td element.
  2. The color must be specified using the hexadecimal short notation, i.e.  #123 instead of #112233
Internet Explorer cannot read short-notation hexadecimal colors in this particular property.  It will instead improvise by applying a background color of black.

The simple solution is to not use the bgcolor attribute, but if you have no control over the markup, use a full-length hexadecimal value instead.  If you're working in an application where you have no control over the markup or the value of this property but can apply CSS with a style sheet, slap the developers in the face and attempt to target the elements to override the color.  Don't try to use attribute selectors though (see here for more information).