W3C home > Mailing lists > Public > www-style@w3.org > January 2015

Re: Extended shorthand for hex colours

From: Simon Pieters <simonp@opera.com>
Date: Thu, 22 Jan 2015 15:28:02 +0100
To: "www-style@w3.org" <www-style@w3.org>, "Ryan Williams" <email@ryanwilliams.co.uk>
Message-ID: <op.xsvbs0x0idj3kv@simons-mbp>
On Thu, 15 Jan 2015 08:59:11 +0100, Ryan Williams  
<email@ryanwilliams.co.uk> wrote:

> Hexadecimal notation is commonly used for defining colours in CSS, but  
> the shorthand is lacking. Right now we can use #CCC which would be  
> expanded to #CCCCCC, but that's pretty much it.
> Wouldn't it be nice if we built upon the principles of the existing  
> shorthand -- repeating the defined characters -- to provide more options?
> For example:
> 1. #C expands to #CCCCCC
> 2. #C3 expands to #C3C3C3

I think this is just confusing. #abc is expanded to #aabbcc, not #abcabc.  
With your proposal you can only express grays, which is not particularly  
useful, and it is not clear from the syntax what it means. Also, it might  
not be Web-compatible to support 1-2 character hex colors. I think it is  
more useful to say that the above are invalid as they are probably typos,  
so that a validator can point out the error.

> 3. #CCC expands to #CCCCCC
> These two extra shorthand formats would allow a lot of hex colours to be  
> typed and/or transmitted across networks more efficiently.

Just use gzip.

> I don't think it'd make sense to allow for four- or five-character  
> shorthand, as the defined characters could not be repeated in full.
> Kind regards,
> --
> Ryan Williams

Simon Pieters
Opera Software
Received on Thursday, 22 January 2015 14:28:34 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:50 UTC