Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the representations of colors in CSS

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what the expression of colors in CSS, I believe most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

English words denote color

The most direct and simplest way is to use English words of color, such as red, we can write it as color:red.

Disadvantages: there are thousands of colors, not every color has corresponding English words, there will be limitations in use.

Binary and hexadecimal color representation

The components of a hexadecimal color are # RRGGBB, where RR (red), GG (green), and BB (blue), all values must be between 0 and FF. Popularly speaking, the essence of hexadecimal is rgb, with every two bits representing a color. It can be abbreviated when the values of every two digits are the same, for example, color:#ffcc00 can be simplified to color:#fc0.

All major browsers support hexadecimal color values and are recommended.

3. RGB represents color

In RGB, R stands for red red, G for green green, and B for blue blue.

RGB is written as "rgb" (0pc0pm 0). Its values range from 0 to 255, and the larger the value, the darker the color. In addition to using numeric values, RGB can also use 100%, with values between 0% and 100%. For example, RGB (0prime0255) and RGB (0% pencil 0% 100%) represent the same color.

The RGB representation of common colors. Red: rgb (255j0jin0); white: rgb (255255255); black: rgb (0re0jue 0)

All major browsers support RGB color values.

4. HSL represents color

HSL color values represent hue, saturation and brightness, respectively.

The degree to which hue is on the color wheel (from 0 to 360)-0 (or 360) is red, 120 is green, and 240 is blue. Saturation is a percentage value, 0% means gray and 100% shadow, is full color. The brightness is also a percentage, 0% is black and 100% is white.

Note: IE9,Firefox,Chrome,Safari, and Opera10+. HSL color values are supported.

For example: use the above four ways to represent different colors, the code is as follows:

HTML section:

There is a bright moonlight in front of the bed

Can it be hoar-frost on the ground

Looking up, I find the moon bright

Bowing, in homesickness I'm drowned

CSS section:

.color1 {background-color:orange;}

.color2 {background-color:#FFFF00;}

.color3 {background:rgb (0pr 255pm 0);}

.color4 {background-color:hsl (360, 50%, 50%);}

The above is all the contents of the article "what are the representations of colors in CSS?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report