When defining colors using “shorthand hexidecimal” (style="color: #FFF;"), is there a defined method for expanding the shorthand? (style="color: #F0F0F0;" or style="color: #FFFFFF;")
Do all browsers use the same expansion method? Is this behavior by specification (if so, where is it defined)? Does the expansion method perhaps vary between CSS 1/2/3?
I’ve observed that “most browsers” expand to #FFFFFF.
Are there any other places (outside of HTML/CSS) where this shorthand notation is allowed, but the expansion method is different?
I’ve always avoided using shorthand hex, because I’ve never known the answers to these questions…
CSS 2.1 (http://www.w3.org/TR/CSS2/syndata.html#value-def-color):
Wordings of CSS 1, CSS 3 are the same. The CSS 4 draft say similar things.
The Internet Explorer and Firefox docs state the same method.
As a practical example, please check out this snippet, which features 3
<div>s of stylesOn Mac OS X 10.6, all Firefox 3.6, Opera 10.10, Safari 4 rendered
#fffas#ffffff.I don’t see a reason why a browser or the standard wants to deviate from this expansion in the future, since the color
#ffffffis far more common than#f0f0f0.