- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
CSS rgb() Function
The rgb() function is used to set RGB color value. The parameter for the function sets the intensity of the color in percentage or value from 0 to 255.
Example
Let us first see an example to implement rgb() in CSS −
<!DOCTYPE html> <html> <head> <style> div { text-align: justify; text-justify: inter-word; color: rgb(213,33,33); background-color: rgb(211,211,211); font-size: 1.1em; } </style> </head> <body> <h2>Demo Heading</h2> <div>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. </div> </body> </html>
Output
Example
Let us now see another example −
<!DOCTYPE html> <html> <head> <style> .demo { grid-area: newArea; font-size: xx-large; } .item3 { font-size: small; } .item4 { font-size: medium; } .item5 { font-size: x-large; } .grid-container { display: grid; grid-template-areas: 'newArea newArea . . .' 'newArea newArea . . .'; grid-gap: 5px; background-color: rgb(0,255,255); padding: 5px; } .grid-container > div { background-color: rgb(255, 50, 80); text-align: center; padding: 5px 0; } </style> </head> <body> <h1>Heading One</h1> <p>Set some random numbers</p> <div class="grid-container"> <div class="demo">250</div> <div class="item2">120</div> <div class="item3">333</div> <div class="item4">298</div> <div class="item5">645</div> <div class="item6">543</div> <div class="item7">555</div> </div> </body> </html>
Output
- Related Articles
- Usage of rgb() CSS function
- Define colors using the Red-Green-Blue model (RGB) with CSS
- Difference Between RGB and CMYK
- CSS rgba() Function
- RGB color to hexadecimal color JavaScript
- Hexadecimal color to RGB color JavaScript
- The CSS rotate() Function
- The CSS scale() Function
- CSS linear-gradient() Function
- The CSS skew() Function
- The CSS matrix() Function
- The CSS translate() Function
- Usage of attr() CSS function
- Usage of var() CSS function
- Usage of calc() CSS function

Advertisements