Languages
[Edit]
EN

JavaScript - convert RGB color to CSS HEX color

8 points
Created by:
Majid-Hajibaba
972

In this short article, we would like to show how to convert RGB color to CSS HEX color using JavaScript.

Practical examples

Edit

RGB color components can be presented in two ranges:

  • from 0 to 1
  • from 0 to 255

In the below sections you can find examples for the both.

RGB (components from 0 to 1)

Edit

 

RGB (components from 0 to 255)

Edit

 

See also

Edit
  1. JavaScript - convert RGB color to HEX color

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join