<p>
paragraph), you can modify its text color using the color
property:
<code class="language-css">p { color: red; }</code>
background-color
property changes the element's background:
<code class="language-css">p { background-color: darkorange; }</code>
rgb()
function defines RGB colors:
<code class="language-css">rgb(<red>, <green>, <blue>)</code>
red
, green
, blue
) accepts an integer value between 0 and 255, representing the intensity of each color component. 0 indicates the weakest intensity, and 255 the strongest. For instance:
<code class="language-css">p { color: rgb(255, 0, 0); /* Equivalent to color: red; */ }</code>
<code class="language-css">p { color: rgb(168, 189, 45); }</code>
rgba()
function extends rgb()
by adding an alpha channel:
<code class="language-css">rgba(<red>, <green>, <blue>, <alpha>)</code>
alpha
parameter (0.0 to 1.0) controls transparency; 0.0 is fully transparent, and 1.0 is fully opaque:
<code class="language-css">p { color: rgba(167, 189, 45, 0.408); }</code>
<code class="language-css">#rrggbb</code>
#
symbol precedes the six-digit hexadecimal code. Each pair (rr
, gg
, bb
) represents the red, green, and blue components, respectively, ranging from 00 (0 decimal) to ff (255 decimal). For example:
<code class="language-css">p { color: #ff0000; /* Equivalent to color: rgb(255, 0, 0); and color: red; */ }</code>
<code class="language-css">#rrggbbaa</code>
aa
represents the alpha channel (00 to ff, mapping to 0.0 to 1.0).
<code class="language-css">p { color: #a7bd2d68; }</code>
rgba(167, 189, 45, 0.408)
.
<p>
hsl()
function uses:
<code class="language-css">p { color: red; }</code>
hue
represents the color's position on the color wheel (0 to 360 degrees).
<p>
<p>saturation
(0% to 100%) indicates the color's intensity (0% is gray, 100% is full color).
<p>
<p>lightness
(0% to 100%) determines the amount of black or white added (0% is black, 100% is white).
<p>
<p>hsla()
adds an alpha channel for transparency:
<code class="language-css">p { background-color: darkorange; }</code>
<code class="language-css">rgb(<red>, <green>, <blue>)</code>
#a7bd2d68
and rgba(167, 189, 45, 0.408)
.
The above is the detailed content of Exploring Colors in CSS. For more information, please follow other related articles on the PHP Chinese website!