RE: Extended shorthand for hex colours

Thanks for the reply. As I so frequently use shorthand to produce greys, I hadn't realised that the expansion uses the format #aabbcc rather than #abcabc. This renders my suggestion less intuitive than I thought.
Out of interest, I took a look around to see whether any of the (pre-)processors out there tackle this issue. Emmet (formerly Zen Coding) seems to use what I suggested:
• #1 -> #111111• #e0 -> #e0e0e0• #fc0 -> #ffcc00
I guess the fact that this functionality exists is an indication that at least some developers would enjoy even shorter shorthand, even if it's only useful for greys — which unlike many tones are in almost every style sheet. Shorthand is ultimately arbitrary and there to speed up development; typos might occur and cause an unexpected result, but that applies to many things in CSS.
The real problem is that web browsers not used to this format would likely render no colour at all, which is a very big obstacle to backwards compatibility due to how critical to a website's readability these values often are. I can't think of a way around that, rendering this idea nice to think about but probably best left to pre-processors.
--Ryan Williamsemail@ryanwilliams.co.uk

> To: www-style@w3.org; email@ryanwilliams.co.uk
> Subject: Re: Extended shorthand for hex colours
> Date: Thu, 22 Jan 2015 15:28:02 +0100
> From: simonp@opera.com
> 
> 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 18:25:55 UTC