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

Re: Extended shorthand for hex colours

From: Pradeep Kumar <pradeep.online00@gmail.com>
Date: Fri, 23 Jan 2015 17:35:02 +0530
Message-ID: <CANkj6une9cHZRkxuh2+X8hcqUxFA62wKngowOSR20rXBz9B4Aw@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Ryan Williams <email@ryanwilliams.co.uk>, "www-style@w3.org" <www-style@w3.org>
What if we can use last two characters for alpha?

Yours
Pradeep Kumar
+91-9582565432
http://prady00.com/

On Fri, Jan 23, 2015 at 12:24 AM, Tab Atkins Jr. <jackalmage@gmail.com>
wrote:

> On Wed, Jan 14, 2015 at 11:59 PM, 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
> > 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.
> >
> > 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.
>
> As other people have said, this has been proposed in the past.  It's
> also been rejected in the past - the only expansion to the hex syntax
> we accepted was to add alpha to it, written as a 4/8 digit hex number.
>
> As Simon says, the WG is generally of the opinion that expanding
> 2-digit hex in the way you suggest is confusing, because it expands in
> a different way than 3/4 digit hex does.  The single-digit hex doesn't
> suffer from this problem, but it's also less useful, only allowing you
> to specify 16 shades of gray, and save two characters doing so.
>
> That said, the underlying purpose of 1/2 digit hex - making it easier
> to specify grayscale without repetition - has been addressed, with a
> gray() function in Colors 4.
> <http://dev.w3.org/csswg/css-color/#grays>  You can provide a
> percentage (0% to 100%) or decimal number (0 to 255) to define a gray,
> without having to repeat yourself (as in rgb()) or specify additional
> junk information (as in hsl()).  It also allows specifying alpha,
> which is something that can't be done with a grayscale hex notation
> (as it would clash with the 3-digit hex notation, not to mention
> having an even more confusing expansion rule).
>
> ~TJ
>
>
Received on Friday, 23 January 2015 12:06:10 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:51:56 UTC