Home > Web Front-end > Front-end Q&A > Font color setting in css

Font color setting in css

WBOY
Release: 2023-05-21 09:13:36
Original
1800 people have browsed it

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.

  1. RGB color

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);
Copy after login

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).

  1. HEX color

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;
Copy after login
  1. Named colors

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;
Copy after login

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;
}
Copy after login

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;
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template