rgb()
Anonymous contributor
Published Jul 21, 2021Updated Nov 14, 2023
Contribute to Docs
Defines a color by providing three comma separated values for red, green, and blue.
Syntax
<property>: rbg(red, green, blue);
where red
, green
, blue
can be one of the following:
- Number values: ranging between
0
and255
- Percentage values: ranging between
0%
and100%
Example 1
Set the font color of the h1
element to be white:
h1 {color: rgb(255, 255, 255);}
Example 2
Set the font color of the h1
element to be black:
h1 {color: rgb(0, 0, 0);}
Example 3
Set the font color of the h1
element to be a lavender color:
h1 {color: rgb(124, 124, 242);}
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn CSS on Codecademy
- Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Free course
Learn CSS
In this CSS tutorial, you’ll learn how to add CSS to visually transform HTML into eye-catching sites.Beginner Friendly6 hours