htmlinternet-explorercolors

Why are 3-digit hex color code values interpreted differently in Internet EXPLORER?


How exactly is Internet Explorer interpreting them, and under which guideline or set of standards?

For instance:

#FFF

is seem as the color white in Google Chrome, for instance, whereas in Internet Explorer (I tested it on 8 and 9) it appears as black.

I code I used to test this was as follows:

<body bgcolor="#ffffff"> vs. <body bgcolor="#fff">

(I am aware that bgcolor is deprecated, it was just convenient for what I was accomplishing at hand).

I am also aware that this is a bug, and that it can be easily fixed by appending a few digits (all-in-all 6) to the hexcode, but I am just interested in seeing the science behind why it occurs, if there is an explanation for it.


Solution

  • I was able to recreate it in IE11 as well. As you know, it is a deprecated attribute. I assume your webpage & the browser are trying to interpret the code as HTML5 and there is a bug in their graceful degradation to handle this. So it just breaks.

    As @Aaron Vanston points out, using inline style or CSS, you can still use the shorthand hex to apply a color.

    I wouldn't even waste my time writing out bgcolor as an attribute. If I came across it in something I was working on, I'd remove it in favor of

    style="background-color: #fff"
    

    or the CSS alternative

    body {
        background-color: "#fff";
    }