The hexadecimal notation #RRGGBB for RGB colour triples has been popularised by HTML and is commonly associated with it, even though nowadays it is not usually used in HTML directly, but rather through CSS.

I noticed that the same notation is used in the X pixmap format (XPM), which to my knowledge was created in 1989, thus predating HTML (1993).

Where does this notation come from? How did it end up in HTML?

  • 5
    This probably has no "answer" in the accepted definition on stack exchange and this site as the notation is the natural one in a world where programmer's commonly deal with machine representations of numbers. Hexadecimal notation was common at that time (as it still is). If there had been color displays a decade earlier RGB notation might have been written in octal - that would have been natural for 666 color on 18-bit or 36 bit machines ... but they still would have switched to hex notation for color when the whole industry went that way ...
    – davidbak
    Mar 9, 2021 at 15:52
  • 11
    @davidbak: Oh come on. The question about $ and about 0x managed to be answered. (I can’t speak as for the correctness of the answer, but…) Mar 9, 2021 at 15:59
  • 3
    If I'm wrong, I'm wrong. That's fine. And that's why I commented, not answered. @texdr.aft - Windows did use that notation as early as 2.0, probably in 1.0 though I don't know.
    – davidbak
    Mar 9, 2021 at 16:17
  • 4
    @davidbak Good to know. It seems likely that it comes from a convention for hexadecimal numbers in general. Wikipedia, without citing any sources, agrees and says that the exact origin was X11 (or an early version thereof) color notation, which was in turn inspired by some assemblers. So far I haven't been able to find any old X windows documentation to verify the claim.
    – texdr.aft
    Mar 9, 2021 at 16:46
  • 8
    @texdr.aft yup, it’s a shame documentation authors never seem to predict and address Retro.SE questions ;-). Mar 9, 2021 at 17:59

1 Answer 1


HTML colours came from X11, being slightly altered first.


The #RGB and #RRGGBB syntax used by WWW was previously present in X11 too.

This 1988 commit tp the X(7) man page describes it (see the section "color names")

xsetroot ( historical version ) calls XParseColor(), and while the current man page for XParseColor() lists #RRGGBB as an allowed format, I was unable to find the corresponding man page on the Xorg site, though the content seems similar to the X(7) page above.

Interestingly, the current man page for XParseColor says that #RGB is scaled to #R0G0B0 rather than #RRGGBB, so #FFF is the same as #F0F0F0 under X11 rather than #FFFFFF (like it is for WWW). This is another departure from X11.

  • Would be good to also include how did it happen that X11 syntax ended up in HTML (as far as I can find, HTML colours were a Netscape invention, and Netscape was primarily an X client, so my guess is that this is where it specifically came from), and where X11 itself took it from (this one might be harder). Mar 16, 2021 at 10:12
  • 1
    Interesting that it specifies zero-extension like that - I would consider that a specification error. (I once wrote some code that had to extend 5 bit-per-channel images up to 8 bit-per-channel and made absolutely sure that 1F multiplied up to become FF...). Mar 17, 2021 at 16:40
  • 2
    Yeah, that is an oddity. perhaps that why it is now deprecated in X11, rgb:fff , the new form, expands to rgb:ffffffffffff. I tested #FFF and it does indeed expand to #F0F0F0
    – Jasen
    Mar 17, 2021 at 20:23
  • 1
    @TobySpeight Something like (x<<3)|(x>>2) ?
    – Leo B.
    Mar 18, 2021 at 6:13
  • 4
    Mosaic - en.wikipedia.org/wiki/Mosaic_(web_browser) - was originally written for X11 on Unix (PC's were not powerful enough yet). Mosaic was the base for Netscape which essentially defined the initial world wide web, so I agree that the X11 notation is a very good guess. May 5, 2021 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .