Using colors that is "right" for your website can have a dramatic impact on how your audience understand your content.
HTML Color Essentials
It is essential to give the user a good user experience. There are many things you should focus on, one of them is how you use colors on your website. We don't have to struggle with black and white TVs anymore. Users expect more and more and we can apply colors to everything we want.
Texts, borders, backgrounds, shadows – in HTML they all can have whatever color you decide. Websites today are better than ever and you should learn how to brighten up your website using some HTML background color magic. You may use HTML color names, Hex color codes, RGB and HSL values. Color Hue is another word for color.
HTML Background Color Using Color Names
There are more than 1100 different color names available. But you should remember that most browsers only support 140 different color names. Using Color Names is one of the most convenient ways to set background color because it is easy to understand what color you have chosen. Color Name keywords are case-insensitive identifiers that represent a specific color, such as black/Black or blueviolet/BlueViolet.
<body style="background-color:BlueViolet;"> </body>
HTML Background Color Using Hex Color Codes
Hexadecimal colors is specified with: #RRGGBB. RR (red), GG (green) and BB (blue) are defined as hexadecimal integers between 00 and FF. Each parameter RR-GG-BB defines the intensity of the color. The hexadecimal color values are supported by all browsers.
<body style="background-color:#8A2BE2;"> <!--Color BlueViolet--> </body>
HTML Background Color Using RGB Color Values
RGB colors are specified with: rgb(red, green, blue). Be sure to enclose the parameter in parentheses and prefix it with a lowercase 'rgb'. The red, green and blue defines the intensity of the color, it is defined as an integer between 0 and 255.
Mixing red with blue makes purple, so RGB works in a similar manner - it mixes different amounts of red, green, and blue to create a color that you want. RGB color values are supported by all browsers.
When using RGB values in HTML you can also specify the level of opacity(transparency). Using the prefix rgba() – the 'a' stands for alpha and it controls the transparency. You can insert a fourth value between 0 and 1, 0 for fully transparent and 1 for totally opaque (use decimal values for levels in between).
<body style="background-color:rgba(138,43,226,1);"> <!--Color BlueViolet--> </body>
HTML Background Color Using HSL Color Values
HSL stands for hue, saturation, and lightness and HSL color values are specified with: hsl(hue, saturation, lightness). HSL color values are supported by all major browsers.
Hue is defined as a degree in the color wheel from 0 to 360. 0 is red, 120 is green, 240 is blue.
Saturation is a percentage value; 0% means a shade of gray and 100% is the full color.
Lightness is a percentage; 0% is black, 100% is white.
You can also specify the level of opacity(transparency) using HSLA, the 'a' is the alpha channel to control the opacity(transparency). You can insert a fourth value between 0 and 1, 0 for fully transparent and 1 for totally opaque (use decimal values for levels in between).
<body style="background-color:hsla(271.1,75.9%,52.7%,1);"> <!--Color BlueViolet--> </body>
HTML Color Contrast
Contrast plays an important role in the success of any website and it ensures the quality of the user experience. Websites with bad contrast can be hard to read and use. It may be easy to determine colors which do not work well together, but it's hard to decide which colors that pair effectively together.
Take a look at the picture to get an understanding of colors you may use together.
- Colors can be represented in many different ways.
- All major browsers support 140 different Color Names and they also support Hex color codes, RGB and HSL values. For example color blue can be represented as blue, #0000ff, #00f, rgb(0,0,255) or hsl(240, 100%, 50%).
- Use background-color to set a background color
- Use color to set the text color
- Use border-color to set a border color.
- Understand what you want to demonstrate and evaluate which colors that will help you in your presentation.