Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
Less.js Color Definition hsv() Function
Next article icon

Less.js Color Definition rgb() Function

Last Updated : 26 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Because CSS uses a dynamic style sheet language, it is more advantageous. LESS is adaptable enough to function in a variety of browsers. A computer language called the CSS pre-processor is used to build and enhance CSS so that web browsers may use it. It is also a language extension for CSS that offers resources like variables, functions, mixins, and operations to aid in the creation of dynamic CSS while maintaining backward compatibility.

In this article, we will see the Color Definition rgb() function in Less.js along with understanding the basic implementation through the illustration. The rgb() function is utilized to generate a hex representation of a color in the format of #RRGGBB and not in #RRGGBB. So this function takes the hex value, RGB value, HSL, or HSV value and it returns a string which is the hex value. This color format is generally utilized in Android development, Internet Explorer & .NET.

Syntax:

rgb( color );

Parameter value:

  • color: This is the compulsory parameter that is a color object, it can be a hex value, RGB value, HSL, or HSV value.

Return type: It returns the string as a final value.

Please refer to the How to pre-compile LESS into CSS article for a detailed description.

Example 1: The below code example demonstrates the usage and implementation of the Color Definition rgb() function.

HTML
<!DOCTYPE html> <html>  <head>     <link rel="stylesheet"          type="text/css" href="style.css" /> </head>  <body>     <h1 style="color:green;">         GeeksforGeeks     </h1>          <h3>Less.js Color Blending rgb() Function</h3>          <div class="c1">         <p>             rgb(0, 153, 200)<br>             (Hex Value)<br>#0099c8         </p>     </div> </body>  </html> 

styles.less:

CSS
@body-bg-color: #eeeeee; @color: rgb(0, 153, 200);  .c1 {       width: 250px;       height: 150px;       margin: 1rem;     background-color: @color;   }   p {       padding: 50px 0px 0px 60px;   }   

Syntax: To compile the above LESS code to CSS code, run the following command.

lessc style.less style.css

The CSS output of the above Less file was compiled into the following file.

style.css:

CSS
.c1 {     width: 250px;     height: 150px;     margin: 1rem;     background-color: #0099c8; }  p {     padding: 50px 0px 0px 60px; } 

Output:

 

Example 2: The below code example demonstrates the usage and implementation of the Color Definition rgb() function with the if and boolean logical functions and the color type function.

HTML
<!DOCTYPE html> <html>  <head>     <link rel="stylesheet"          type="text/css" href="style.css" /> </head>  <body>     <h1 style="color:green;">         GeeksforGeeks     </h1>          <h3>Less.js Color Blending rgb() Function</h3>          <div class="c1">         <p>             rgb(hsl(150, 100%, 39%))<br>             (Hex Value)<br>#00c763         </p>     </div> </body>  </html> 

styles.less:

CSS
@body-bg-color: #eeeeee; @color: rgb(hsl(150, 100%, 39%)); @second: rgb(255, 19, 19); @cond1: boolean(iscolor(@second));  .c1 {       width: 250px;       height: 150px;       margin: 1rem;     background-color: if(@cond1, @color, @second);   }   p {       padding: 50px 0px 0px 60px;   }   

Syntax: To compile the above LESS code to CSS code, run the following command.

lessc style.less style.css

The CSS output of the above Less file was compiled into the following file.

style.css:

CSS
.c1 {     width: 250px;     height: 150px;     margin: 1rem;     background-color: #00c763; }  p {     padding: 50px 0px 0px 60px; } 

Output:

 

Reference: https://lesscss.org/functions/#color-definition-rgb 


Next Article
Less.js Color Definition hsv() Function

P

priyanshuchatterjee01
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • LESS
  • Less.js-Functions

Similar Reads

  • Less.js Color Definition rgba() Function
    Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Because CSS uses a dynamic style sheet language, it is more advantageous. LESS is adaptable enough to function in a variety of browsers. A computer language called
    3 min read
  • Less.js Color Definition Functions
    Less (Leaner Style Sheets) is an extension to normal CSS which basically enhances the abilities of normal CSS and gives it programmatic superpowers. In this article, we are going to see Color Definition functions in Less.js.  Color definition functions are provided by Less.js, which basically are us
    3 min read
  • Less.js Color Definition hsl() Function
    Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is better since CSS makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. To create and improve CSS so that
    3 min read
  • Less.js Color Definition hsv() Function
    Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is better since CSS makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. To create and improve CSS, so that
    3 min read
  • Less.js Color Definition argb() Function
    Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. CSS is more beneficial because it makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. The CSS pre-processor i
    3 min read
  • Less.js Color Definition hsva() Function
    Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. Since CSS uses a dynamic style sheet language, it is superior. LESS is adaptable enough to function in a variety of browsers. A computer language called the CSS pr
    4 min read
  • Less.js Color Definition hsla() Function
    Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. CSS is better since it makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. CSS is created and improved using
    3 min read
  • Less.js Color Operation fadein() Function
    Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is better since CSS makes use of a dynamic style sheet language. LESS is flexible enough to work in a wide range of browsers. To create and improve CSS so that
    3 min read
  • D3.js | color.rgb() Function
    The color.rgb() function in D3.js is used to return the RGB equivalent of the specified color. Syntax: color.rgb() Parameters: This function does not accept any parameters. Return Value: This function returns the RGB equivalent of the specified color. Below programs illustrate the color.rgb() functi
    1 min read
  • Less.js Color Operation darken() Function
    Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is more advantageous because CSS employs a dynamic style sheet language. Several different browsers can use LESS because of its flexibility. In order for web br
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences