HTML Code for Colors

CSS provides the color property and the background-color properties, both of which can be applied to any HTML element.

And there's the border-color and outline-color properties for borders and outlines. There's also a property for each side of the box (for example, border-top-color, border-bottom-color and so on.

You can also specify color for borders with the border property (which allows you to set all border properties in one go), and likewise for outlines with the outline property.

Colors can be defined using either its color name, its hexadecimal value, or its RGB value.

Examples of Setting Color using Inline Styles:

If you don't want to specify the color everytime an element appears, you can declare it in the document head or, even better, in an external stylesheet.

You can also check out the HTML color page to learn about colors in HTML and CSS.