Color names let you pick colors by simple words instead of codes. This makes styling easier and faster.
Color names in CSS
property: color-name;Use any CSS property that accepts colors, like color, background-color, or border-color.
Color names are case-insensitive, so Red and red work the same.
color: red;background-color: lightblue;border: 2px solid green;
This webpage uses color names to style the background, heading, and paragraph. You will see a light yellow page background, a dark blue text color for the body, a crimson heading, and a light green paragraph with an orange border.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Color Names Example</title> <style> body { background-color: lightyellow; color: darkblue; font-family: Arial, sans-serif; padding: 2rem; } h1 { color: crimson; } p { background-color: lightgreen; border: 3px solid orange; padding: 1rem; max-width: 400px; border-radius: 0.5rem; } </style> </head> <body> <h1>Welcome to Color Names</h1> <p>This paragraph uses color names for background, border, and text colors.</p> </body> </html>
Color names are easy but limited to about 140 standard colors.
For more precise colors, you can use hex codes or RGB values.
Always check color contrast for readability and accessibility.
Color names let you use simple words to set colors in CSS.
They work with many CSS properties like color and background-color.
Use color names for quick, readable, and browser-friendly color styling.