W3C home > Mailing lists > Public > www-style@w3.org > April 2012

Re: [css4-color] Grayscale shorthand (with alpha)

From: Simon Sapin <simon.sapin@kozea.fr>
Date: Tue, 17 Apr 2012 12:46:21 +0200
Message-ID: <4F8D49FD.6050806@kozea.fr>
To: www-style@w3.org
Le 17/04/2012 11:01, Rudolph Gottesheim a écrit :
> I find myself writing things like rgba(0, 0, 0, .5) or rgba(192, 192,
> 192, .8) dozens of times a day, mostly for shadows. It's always some
> shade of gray with some alpha value.
>
> Do you think there's room for a grayscale color shorthand?
>
> Maybe something like *gray(255, .5)* == rgba(255, 255, 255, .5) or
> *la(50%, .9)* == hsla(0, 0%, 50%, .9)
>
> It probably seems like the few saved characters aren't worth a new
> function or syntax, but it just seems so redundant every time I type
> this stuff out. rgba(255, 255, 255, .2) ... ugh.
>
> What do you think?


I like the idea.

If my math is correct, hsla(X, 0%, Y%, Z) is always the same as rgba(Y%, 
Y%, Y%, Z). gray(Y%, Z) could be a shorthand for these, and gray(Y%) a 
shorthand for gray(Y%, 1)

Also, accept an integer in 0-255 as well as a percentage.

(Let the bike-sheding begin for the function name.)

-- 
Simon Sapin
Received on Tuesday, 17 April 2012 10:46:53 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:52 GMT