iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

CSS Color Keywords

CSS ships ~140 named colour keywords. They're memorable, easy to read in code, and never need a hex lookup.

A representative sample

KeywordHexNotes
black#000000Pure black.
white#FFFFFFPure white.
red#FF0000Pure red. Brighter than most designers want.
tomato#FF6347Softer red — popular for accents.
steelblue#4682B4Muted, professional blue.
seagreen#2E8B57Restful natural green.
gold#FFD700Warmer than yellow.
rebeccapurple#663399Added to honour Rebecca Meyer; spec gem.
transparentFully transparent.
currentColorInherits the element's text colour.

System keywords

Special names that take their value from the OS or browser theme:

  • Canvas / CanvasText — the OS "page" background and text colour.
  • LinkText / VisitedText — system link colours.
  • ButtonFace / ButtonText — native button surface.
  • Mark / MarkText — highlighting colours.
Tip: Named colours are fine for prototypes and CSS variables. For brand colours, store the hex in a variable so it lives in one place.

Example

Example
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Verdana, sans-serif; }
.box { background: #04AA6D; color: #fff; padding: 20px; border-radius: 6px; }
</style>
</head>
<body>

<h1>CSS Color Keywords</h1>
<div class="box">Edit the CSS on the left, then click Run &raquo;</div>

</body>
</html>
Try it Yourself »

Exercise

Use the named keyword that means fully transparent.

.overlay { background: ; }

Test yourself

Q1. About how many named CSS colour keywords are there?
Q2. Which keyword means fully transparent?
Q3. Which keyword inherits the OS theme text colour?

Discussion

Loading…