Issue
As someone who primarily uses British English, the fact that CSS does not accept colour
as a valid property is rather irksome, especially when it accepts grey
(and its deviations) as valid values. Why would CSS allow for British English in values, not but in properties?
According to the W3 CSS color specification, the official spelling for the CSS color
value is gray
:
However, it also accepts grey
(and its deviations) just fine:
.gray {
color: gray;
}
.grey {
color: grey;
}
<span class="gray">gray</span>
<span class="grey">grey</span>
This also makes sense, given that the X11 color names (which CSS Colors Level 3 adapted from) list the grey
spellings as valid alternatives.
But why then, does CSS Colors Level 3 not allow for colour
as a property?
.color {
color: red;
}
.colour {
colour: red;
}
<span class="color">color</span>
<span class="colour">colour</span>
Is there a specific reason that the creators of the specification would allow for alternatives to values but not properties?
Solution
Quite interestingly, the history of this choice is quite well documented.
The CSS specs has this issue which talks about this point. In there Tab Atkins(tabatkins) links to this video of a JSConf given by Alex Sexton about the (quite fascinating and funny) history behind the CSS named colors.
According to Sexton, the grey
value was initially added to MIT's rgb.txt file that specifies "X11 colors", because
some programmers at HP couldn't remember which one was right.
A few years later, Chris Lilley(svgeesus) will add these values to the SVG colors, and finally CSS3 (as early as in 2001) will follow as Ian Hickson(Hixie) puts it,
[...] merely to codify current practice. Almost every browser supports them and that isn't going to change (because it would break many sites [...]
Now, that doesn't tell us why we don't have a colour
attribute. For this let's come back to the CSS issue where tabatkins gives a hint that this is a recurrent request. The same svgeesus that did add the named colors to SVG back then also intervenes in this thread and explains that
The aliasing of international-English grey and US-English gray is least problematic as a property value (but would probably still not be adopted, were those keywords to be proposed today). As a functional notation, it would be more problematic; it would require precedence and de-duplicating rules in case both were specified. Even more so for aliasing the
color
property tocolour
(and the same for all the*-color*
properties.Sorry, this would add far more issues than it solves.
Answered By - Kaiido
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.