HTML: Define color codes - how it works
You can define colors in HTML in different ways. We show you how to do this.
Define color codes in HTML
Basically, you can define colors in HTML in two ways - either with color names or hexcodes. Color names are more memorable, but most web developers use hexcodes to code the colors:
- Hexcode: The hexadecimal number always has six digits for color coding. The first two digits stand for the red component, the next two for green and the last two for the blue component. There is always a diamond sign in front of a color: "#". So you can define a red background color like this: "". Please note that the spelling is out of date without style sheets. For example, avoid this code: "".
- Color names: They basically work the same way as hex codes. You could create a red background like this: "". You can find detailed tables with hundreds of color names on the Internet.
It is more professional to move the color definitions to an external stylesheet (CSS). In another practical tip, we explain the differences between HTML and CSS.