Home > Article > Web Front-end > Font color setting in css
In web design, font color is a very important factor. By setting the font color, you can make your web page more attractive, easier to read, and help convey your brand image. Setting font color in CSS can use RGB, HEX values or named colors.
RGB color is generated by different combinations of the three primary colors of red, green, and blue. In CSS, you can use the rgb() function to represent RGB colors. For example, to set the red font, you can use the following code:
color: rgb(255,0,0);
where the first parameter is the red value (0-255), the second parameter is the green value (0-255), and the third The parameters are blue values (0-255).
HEX color is a hexadecimal notation that can also be used to set font color. HEX color consists of 6 characters, the first two characters represent the red value, the middle two characters represent the green value, and the last two characters represent the blue value. For example, to set a dark blue font, you can use the following code:
color: #00008B;
CSS also predefines the names of some common colors, and you can use them directly to set the font color. For example, to set a black font, you can use the following code:
color: black;
In addition to black, there are also a series of color names such as red, green, blue, etc. that can be used.
When setting the font color, you can write the color attribute in the universal selector "*" to keep the font color of all elements uniform. For example, to make the font color of all elements black, you can use the following code:
*{ color: black; }
In addition, it is also very important to set the font color of hyperlinks with CSS. Typically, unvisited links appear in blue and visited links appear in purple. You can use the following code to set the font color of a hyperlink:
a:link{ color: blue; } a:visited{ color: purple; }
In CSS, you can use RGB colors, HEX colors, and predefined color names to set font colors. By setting font colors appropriately, you can make your web pages more attractive, easier to read, and help convey your brand image.
The above is the detailed content of Font color setting in css. For more information, please follow other related articles on the PHP Chinese website!