background colors HTML curiositiy

Neomega

Deity
Joined
Feb 9, 2002
Messages
11,261
I was playing around with tables, and I tried to type in transparent after "none" produced black, (I was seeing If I could make an effect work)

Much to my surprise, transparent displayed as a form of blue!

What?

So I typed in bgcolor=what next, and it was a dark green!

Anyone know why, I tried some other words, and they also displayed various colors. "When" was very close in color to "what", but who was all black.

I am really curious now, how is HTML deciding what these words represent?
 
I would think the interpreter is making the best of a bad job. Maybe what is read as #what00 or something like that?

#000000 is black, #EEEEEE is a very light grey, #FFFFFF is white... etc.
 
but i thought it could only read hex values or RGB sets, or the preset color names.....


{edit}
Right, I use the hex values all the time for coloring... but w is not a valid letter, nothing above f is.
 
It interprets the letters it can understand (a-f) and assumes any others, or those left out, are 0. Thus, what -> #00a000, when -> #00e000, away -> #a0a000, and atacam -> #a0a0a0.

If the word is longer than six characters, then the browser tries to begin at the beginning and end at the end. Thus, the first two characters are the red specification, and if there is an even number of characters, then the last two are the blue spec and the middle two are the green spec. If there is an odd number of characters, then it drops the last character and applies the even algorithm to the rest of the word. Thus,

transparent -> #trspen -> #0000e0
marvelous -> #maveou -> #0a0e00
civfanatics -> #cianic -> #c0a00c

They say that 3/4 of the code in browsers is entirely to deal with the errors that html allows. This is an example of the power of that...
 
So it divides the word by three, with remainders, (to signify the RGB in hex), and then starts tacking the remainders on, one by one, on the R, G, and B values?

WOW!

Thanks IbnSina, that satisfied my curiosity completely.

:)
 
Back
Top Bottom