IE7 lacks support for abbreviated color codes in deprecated HTML tags

February 17th, 2008 | by ndunn@webucator.com |

A good response to this title might be “who cares?” We all should be using CSS to handle color anyway, right? Sure, that’s right. However, I still sometimes use the old deprecated attributes when I’m whipping something small together. I can save a few keystrokes (nine to be exact) by typing <tr bgcolor="#f00"> rather than <tr style="background:#f00">. Well, I guess I can’t - not if I’m going to need my page to work in IE as well as Firefox. IE7 doesn’t recognize the abbreviated hex code. If you’re going to use the deprecated bgcolor attribute, you’re stuck with the six-character hex codes (e.g, <tr bgcolor="#ff0000">). And there goes three of my saved keystrokes. For nine saved keystrokes, I’ll use a deprecated attribute from time to time, but for six it just isn’t worth it. :)

For those of you who are geeky enough to want to test this, but not interested enough to write the code yourself, here’s the code that works in Firefox, but not in IE:

<table>
    <tr bgcolor="#f00">
        <td>Hello world!</td>
    </tr>
</table>

And here’s how it renders:

Hello world!

Now hold on just a minute! That’s not working. And it took me a little while to find out why. It turns out WordPress (blog platform used by Webucator) won’t let me make my mistake. It’s “correcting” my code and converting #f00 to #000000. I’m afraid that means you’ll have to run the test yourself. When you do (and I’m sure you will), be sure to include the DOCTYPE declaration. Otherwise, Firefox will also paint that red door black.

You must be logged in to post a comment.