RGB to HEX Converter
Convert RGB (Red, Green, Blue) color values to HEX color codes. HEX is the standard format for colors in web development, CSS, and HTML. This converter translates RGB values instantly to their hexadecimal equivalents.
Understanding the Conversion
RGB uses decimal values (0-255), while HEX uses hexadecimal (00-FF). Each RGB component converts to a two-character HEX value:
| RGB Value | HEX Value | 255FF 12880 000 | 200 | C8 |
Conversion Formula
To convert RGB to HEX: 1. Convert each decimal value (0-255) to hexadecimal (00-FF) 2. Combine as #RRGGBB
Example: rgb(255, 128, 64)
- 255 → FF
- 128 → 80
- 64 → 40
- Result: #FF8040
Common RGB to HEX Conversions
| Color | RGB | HEX | Redrgb(255, 0, 0)#FF0000 Greenrgb(0, 255, 0)#00FF00 Bluergb(0, 0, 255)#0000FF Yellowrgb(255, 255, 0)#FFFF00 Cyanrgb(0, 255, 255)#00FFFF | Gray | rgb(128, 128, 128) | #808080 |
Using HEX in CSS
``css
.element {
color: #FF5733;
background-color: #F0F0F0;
border-color: #333333;
}
``
Shorthand HEX
When each pair has identical digits, use 3-character shorthand:
- #FF0000 → #F00
- #336699 → #369