a guide to conceiving, creating & publishing your own website
Using CSS, you can change the colour of several things: most commonly, text and backgrounds. Everything that can be coloured with CSS accepts the same colour values in the same way.
To change the text and background colour of any element with CSS, the color and background-color properties are required. Those used to the Commonwealth spellings of words must to re-train their muscle memory.
body {
color: white;
background-color: black;
}
This is a pair of CSS rules applied to the body using defined colour names. It forces the text to be white on black, instead of the browser's default black on white.
When changing the colour of a document's background, always be sure to declare the text colour too, and vice versa. Your browser might have black text as the default, but somebody using dark mode settings might have white text by default—if you set the background to yellow, the text becomes unreadable.
CSS has a total of 148 named colours, corresponding to defined hex values, that you can use in your code with no problem. Every browser understands the values red and royalblue and lightgoldenrodyellow.
A visual list of named colours is available on this website for reference.
xxx
xxx
xxx
xxx
Not everyone has Comic Sans!
xxx
xxx
xxx
xxx