The many ways to write a color in CSS
Tags: css, html, color
Published: 2020-08-28 03:27:14

---
title: The many ways to write a color in CSS
published: true
description: There are over 78 different ways to write the same color name in CSS... how many do you know?
tags: css,html,color
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/p9o7kc5zgl0qpkqso885.png
---

Hi! My name is Cyan, and I am a Color. I'm not as popular as I used to be –not trying to brag, but I was a hit on the Internet in the 90s & early 2000s–, and I am still quite eye-catchy:

<figure>
![Big rectangle with nothing but cyan color](https://dev-to-uploads.s3.amazonaws.com/i/ibr8nl47ygjem5w5a36b.png)
<figcaption>This is a recent picture of me</figcaption>
</figure>

With the many changes on the web and CSS, I've been going through an identity crisis. People call me in different ways, and I am starting to forget who I really am.

You see, **[some colors have names](https://dev.to/alvaromontoro/named-colors-2bep), some others don't... and some others have multiple names!** For example, I am Cyan, but some random people call me Aqua! (yes, like the Barbie Girl band!)

1. `cyan`
2. `aqua`

I have to say Aqua is a cool name, it has a ring to it, but I still feel more like a Cyan. Although I must admit, it is nice to have two names.

You may find amazing that we colors have "color languages" similar to the human languages you have. And my name can be translated to many of them!

For example, there's [**RGB** (which stands for Red-Green-Blue)](https://dev.to/alvaromontoro/rgb-50hg). In it, a color can be written in many ways: with and without transparency (alpha), using percentages or numbers, using the `rgb()` or `rgba()` functions...

There are **24 ways to write my name in RGB**:

3. `rgb(0, 255, 255)`
4. `rgb(0, 255, 255, 1)`
5. `rgb(0, 255, 255, 100%)`
6. `rgb(0%, 100%, 100%)`
7. `rgb(0%, 100%, 100%, 1)`
8. `rgb(0%, 100%, 100%, 100%)`
9. `rgb(0 255 255)`
10. `rgb(0 255 255 / 1)`
11. `rgb(0 255 255 / 100%)`
12. `rgb(0% 100% 100%)`
13. `rgb(0% 100% 100% / 1)`
14. `rgb(0% 100% 100% / 100%)`
15. `rgba(0, 255, 255)`
16. `rgba(0, 255, 255, 1)`
17. `rgba(0, 255, 255, 100%)`
18. `rgba(0%, 100%, 100%)`	
19. `rgba(0%, 100%, 100%, 1)`
20. `rgba(0%, 100%, 100%, 100%)`
21. `rgba(0 255 255)`
22. `rgba(0 255 255 / 1)`
23. `rgba(0 255 255 / 100%)`
24. `rgba(0% 100% 100%)`
25. `rgba(0% 100% 100% / 1)`
26. `rgba(0% 100% 100% / 100%)`

Then we have [**HEX**](https://dev.to/alvaromontoro/hexadecimal-rgb-hex-2cp2), which is a type of RGB. My name can be written in **4 HEX ways**: in a long or short form, and with transparency (alpha) or without it.

27. `#00ffff`
28. `#0ff`
29. `#00ffffff`
30. `0fff`

My favorite _color language_ is [**HSL** (Hue-Saturation-Lightness)](https://dev.to/alvaromontoro/hsl-2fom). If it were a human language, it would be French. It is stylish, beautiful, and sounds sexy... plus it supports alpha and many options.

That's why I am so happy that my name can be written in **24 different ways in HSL** (but I won't be changing it from Cyan any time soon):

31. `hsl(180, 100%, 50%)`
32. `hsl(180, 100%, 50%, 1)`	
33. `hsl(180, 100%, 50%, 100%)`	
34. `hsl(180deg, 100%, 50%)`
35. `hsl(180deg, 100%, 50%, 1)`	
36. `hsl(180deg, 100%, 50%, 100%)`	
37. `hsl(180 100% 50%)`
38. `hsl(180 100% 50% / 1)`	
39. `hsl(180 100% 50% / 100%)`	
40. `hsl(180deg 100% 50%)`
41. `hsl(180deg 100% 50% / 1)`	
42. `hsl(180deg 100% 50% / 100%)`
43. `hsla(180, 100%, 50%)`
44. `hsla(180, 100%, 50%, 1)`	
45. `hsla(180, 100%, 50%, 100%)`
46. `hsla(180deg, 100%, 50%)`
47. `hsla(180deg, 100%, 50%, 1)`	
48. `hsla(180deg, 100%, 50%, 100%)`	
49. `hsla(180 100% 50%)`
50. `hsla(180 100% 50% / 1)`	
51. `hsla(180 100% 50% / 100%)`	
52. `hsla(180deg 100% 50%)`
53. `hsla(180deg 100% 50% / 1)`	
54. `hsla(180deg 100% 50% / 100%)`

Those are the languages that I speak more fluently, and almost every color and browser can understand them, which is nice.

Then, one day CSS changed and decided to add new languages. They are a bit challenging sometimes because they are written slightly differently... but I told myself, "Hey, Cyan! you can do it!" And I am trying to learn them too.

I started with [**HWB** (Hue-Whiteness-Blackness)](https://dev.to/alvaromontoro/hwb-13h7) because it reminds me of HSL. It is new and doesn't have many bells and whistles, but it sounds elegant:

55. `hwb(180 0% 0%)`
56. `hwb(180 0% 0% / 1)`
57. `hwb(180 0% 0% / 100%)`
58. `hwb(180deg 0% 0%)`
59. `hwb(180deg 0% 0% / 1)`
60. `hwb(180deg 0% 0% / 100%)`

On the side, I am trying to learn Lab and LCH... unfortunately I don't think my name can be completely translated into those color languages... or maybe the problem is quite the opposite. They are tough!

In [**Lab** (aka CIE L*a*b*)](https://dev.to/alvaromontoro/lab-4a9k), my name can be written in **3 different ways**:

61. `lab(90.67% -50.67 -14.96)`	
62. `lab(90.67% -50.67 -14.96 / 1)`	
63. `lab(90.67% -50.67 -14.96 / 100%)`

It is also the number of ways that it can be written on [**LCH** (Lightness-Chroma-Hue)](https://dev.to/alvaromontoro/lch-3p28): **3**.

64. `lch(90.7% 52.8 196.5)`	
65. `lch(90.7% 52.8 196.5 / 1)`	
66. `lch(90.7% 52.8 196.5 / 100%)`

And last but not least, I started practicing [**CMYK** (Cyan-Magenta-Yellow-Key)](https://dev.to/alvaromontoro/cmyk-1mo4). I left it for last because I was sure that it had to be a good one... after all, it has my name.

And it is good... although a bit complicated for my liking, and not many browsers understand it (none to be precise). Which is sad because it has everything I like: multiple notations, transparency, fallbacks!

My name can be written in **12 different ways in CMYK**:

67. `device-cmyk(1 0 0 0)`	
68. `device-cmyk(1 0 0 0 / 1)`	
69. `device-cmyk(1 0 0 0 / 100%)`	
70. `device-cmyk(1 0 0 0, #00FFFF)`	
71. `device-cmyk(1 0 0 0 / 1, #00FFFF)`	
72. `device-cmyk(1 0 0 0 / 100%, #00FFFF)`	
73. `device-cmyk(100% 0% 0% 0%)`	
74. `device-cmyk(100% 0% 0% 0% / 1)`	
75. `device-cmyk(100% 0% 0% 0% / 100%)`	
76. `device-cmyk(100% 0% 0% 0%, #00FFFF)`	
77. `device-cmyk(100% 0% 0% 0% / 1, #00FFFF)`	
78. `device-cmyk(100% 0% 0% 0% / 100%, #00FFFF)`


And that's it.

...or kind of. Because then we have the [`color()` function](https://dev.to/alvaromontoro/the-color-function-4km2) that is like a super-power color translator. With it, I can define my name and write it in many different ways with many different fallbacks (in case people don't understand it the first time I say it).

So... that makes it 2 named colors, 24 RGB colors, 4 HEX colors, 24 HSL colors, 6 HWB colors, 3 Lab colors, 3 LCH colors, and 12 CMYK colors... which adds up to 78. Seventy-eight!

Do you understand my identity crisis now? **I am but a humble color, and I have over 78 different names!** And that's not counting the `color()` function and all the possible fallbacks. Then I have infinite names!

But rest assured, it doesn't matter how many different names I have. I will always be Cyan.