I'd give them semantic names (like you have here), but use those semantic variables to reference the .bg-mallard or whatever - so in "use" you're only using .bg-primary-brand, but the base primitive color is .bg-mallard so you have a name to reference against a style guide Answer from OrtizDupri on reddit.com
๐ŸŒ
W3Schools
w3schools.com โ€บ cssref โ€บ css_colors.php
CSS Colors
All modern browsers support the following 140 color names (click on a color name, or a hex value, to view the color as the background-color along with different text colors): For a full overview of CSS colors, visit our colors tutorial.
๐ŸŒ
Austin Gil
austingil.com โ€บ css-named-colors
CSS Named Colors: Groups, Palettes, Facts, & Fun โ€“ Austin Gil
January 23, 2023 - This page provides resources for working with CSS Name Colors. It contains Named Color groups, palettes, favorites, and even fun facts.
๐ŸŒ
HTML Color Codes
htmlcolorcodes.com โ€บ color-names
Color Names โ€“ HTML Color Codes
Modern browsers support 140 named colors, which are listed below. Use them in your HTML and CSS by name, Hex color code, RGB or HSL value.
๐ŸŒ
147 Colors
147colors.com
147 Colors Grid - CSS Color Names
A tool for web designers and developers to learn the 147+ CSS color names that are available today.
Find elsewhere
๐ŸŒ
Reddit
reddit.com โ€บ r/web_design โ€บ how would name these colors in the css?
r/web_design on Reddit: How would name these colors in the CSS?
March 24, 2024 -

I'm trying to figure out what the best naming conventions are for the color palette below. I'm doing a bit over an overhaul to the CSS and want to future-proof it. I currently have them named by their color name, for example #006552 is .bg--mallard. However, this is turning out to be a bit of a problem when I need to change a color. Basically it results in having to update the class name in multiple files so I'm looking to name them something more abstract.

I've read it's better to name them based on their meaning or purpose, something like:

  • bg--primary-brand

  • bg--primary-brand-2

  • bg--secondary-1

  • bg--secondary-2

  • bg--secondary-3

  • bg--accent-1

  • etc...

Are there any tried and true methods I should be looking into? Thanks.

Top answer
1 of 5
2
I'd give them semantic names (like you have here), but use those semantic variables to reference the .bg-mallard or whatever - so in "use" you're only using .bg-primary-brand, but the base primitive color is .bg-mallard so you have a name to reference against a style guide
2 of 5
2
I don't think there's a "one fits all" solution, as it always kinda depends on both your design system as well as the technicalities of the project. For example, when I make a web project that has multiple themes (e.g. light and dark mode), my color variables are usually completely detached from the design system and are purely based on how the color/variable will be used. In such a project, I would have variables like: --text-primary --text-secondary --text-negative --background-primary --background-secondary --accent --accent-dark --accent-light Because when working with multiple themes, I find it important to know what elements are affected by each variable. But your project might not be a web app and you are working with a lot of colors, and we're not even not even talking about shades yet (which you usually need e.g. for hover states). When working with such a complex design system, it might make more sense to bring it into your CSS directly and potentially assign it to a variable named after it's intended usage. Here's just my idea of what I would probably do with this: I'm using SASS (and I'd highly recommend it to anyone), so I'd have a colors.scss file where everything color-related is managed. First, I would define the colors as SCSS variables and name them after the color, so $accent-magenta, $accent-orange and so on, and also include shades like $accent-orange-light (if the design system doesn't define shades, you can use SASS to scale the color). These variables will not be used outside of this file. Instead, I would use them to define CSS-variables that are once named after their intended purpose. That would result in variables like: --button-primary: $accent-orange; --button-primary-hover: $accent-orange-light; --button-primary-text: $neutral-light; --text-primary: $neutral-dark; --text-secondary: $neutral-medium; --navbar-background: $primary-lightgreen; --navbar-text: $neutral-light; and so on. So outside of the colors.scss file, you would only use the CSS-variables that are detached from the color and named after their application. In the colors.scss, you assign each application one of the colors. One color may also be used for multiple applications. This way, you don't need to worry about color names in your CSS while still having access to your whole design system. But as I said, that's all just how I would do it and I can't promise it will work for you.
๐ŸŒ
W3Schools
w3schools.sinsixx.com โ€บ css โ€บ css_colornames.asp.htm
CSS Color Names - SinSiXX - W3Schools
Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building.
๐ŸŒ
Quackit
quackit.com โ€บ css โ€บ css_color_codes.cfm
CSS Color Codes
Use the following color picker or color charts to pick a color that you can use within your CSS code. The color picker provides the color values in hexadecimal and RGB. The color chart provides them in hexadecimal, RGB, and their color names.
๐ŸŒ
Quackit
quackit.com โ€บ css โ€บ color โ€บ charts โ€บ css_color_names_chart.cfm
CSS Color Names Chart
Full list of the official CSS named colors. Includes the equivalent RGB hex and decimal codes.
๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ css-reference โ€บ css-color-names.php
CSS Color Names - List of Color Keywords, Hex and RGB Values
Get the complete list of basic and extended color keywords as well as their hex and RGB color values. You can further fine tune the color using shades option.
๐ŸŒ
W3C
w3.org โ€บ wiki โ€บ CSS โ€บ Properties โ€บ color โ€บ keywords
CSS/Properties/color/keywords - W3C Wiki
ThreeDShadow The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border. Window Window background. WindowFrame Window frame. WindowText Text in windows. Retrieved from "https://www.w3.org/wiki/index.php?title=CSS/Properties/color/keywords&oldid=52690"
๐ŸŒ
DoFactory
dofactory.com โ€บ css โ€บ color-names
CSS Color Names
CSS solor names are constant color values such as, red, purple, and teal. Color names can be used as color values in HTML and CSS. The same color names are also used by WPF and Silverlight. All modern browsers support 140 color names.
๐ŸŒ
Prince
princexml.com โ€บ doc โ€บ 15 โ€บ css-color-names
Color Names ยท Prince Documentation
CSS offers several ways of defining colors - either by keyword, or by numerical specification expressed as RGB(A), CMYK, HSL(A), or HWB colors. For more details, please see the chapter on Color. Color keywords are an easy way of expressing colors by naming them. The names resolve to colors in sRGB.
๐ŸŒ
W3Schools
w3schools.com โ€บ tags โ€บ ref_colornames.asp
HTML Color Names
All modern browsers support the ... a color name, or a hex value, to view the color as the background-color along with different text colors): For a full overview of HTML colors, visit our colors tutorial. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com ยท HTML Tutorial CSS Tutorial ...
๐ŸŒ
Ditig
ditig.com โ€บ css-named-colors
CSS named colors - Ditig
April 18, 2025 - Contains a list of all CSS Color Module Level 4 named colors โ€” listed with hex, RGB, and HSL values.
๐ŸŒ
Ado
ado.xyz โ€บ blog โ€บ custom-css-color-names
How to Create Custom CSS Named Colors - Ado.xyz
March 25, 2021 - In an earlier post, we looked at Named Colors in CSS. Currently there are 147 named CSS colors that you can use, ranging from primary colors like red, green, and blue, to more exotic choices like tomato, aquamarine, and mediumslateblue. But what if you want to have your own named CSS colors?
๐ŸŒ
Chirag Mehta
chir.ag โ€บ projects โ€บ name-that-color
Name that Color - Chirag Mehta : chir.ag
Being a typical guy, I have no clue what the colors Lavender and Mauve look like. You can show me Indigo and I won't know if it's more like Violet or Purple. So I made this little app where you can create a color on the screen (or copy-paste CSS hex# color) and find out the name of the closest matching color.
๐ŸŒ
CSS Portal
cssportal.com โ€บ css-color-names
CSS Color Names - CSS Portal
A complete CSS color names list with samples, HEX codes and RGB values - perfect for finding and choosing colors in your web projects.