RGB gives you three decimal channels between 0 and 255. Converting to HEX turns each channel into a two-digit hexadecimal number, so the whole color fits into one compact token that every browser, design tool and style guide understands.
Yuav ua li cas RGB rau HEX hloov ua haujlwm
- Tso lub xov tooj liab (red channel) thiab faib nws rau 16: qhov kis yog tus lej thawj, qhov seem yog tus lej thib ob.
- Sau cov lej 10 txog 15 ua cov ntawv A txog F — 255 yuav yog FF.
- Ua tib yam rau ntsuab thiab xiav, ntxiv qhov 0 ua ntej yog tias tsuas yog ib tus lej: 5 yuav yog 05.
- Koom peb lub khub thiab muab ib # tso rau pem hauv ntej.
Qhia ua piv txwv
Zoo meej, yog tias cov channel yog txhua tus lej tag nrho txij 0 txog 255. Cov nqi uas muaj faib xws li rgb(79.5, 70, 229) yuav raug puav pheej mus rau tus lej tag nrho ze tshaj plaws ua ntej, vim HEX tsis khaws tau qee yam nruab nrab.
RGB thiab HEX piav
Dab tsi yog RGB?
RGB piav txog xim ua peb lub channel ntawm teeb — liab, ntsuab thiab xiav — txhua tus los ntawm 0 txog 255. Nws cia raws li cov zaub ua haujlwm tiag: tag nrho peb ntawm 255 yog dawb, tag nrho ntawm 0 yog dub. RGB yog qhov kev xaiv thaum twg koj xav xam nrog xim, thiab rgba() ntxiv kev pom qhov muag (transparency) ntxiv.
- Syntax:
- rgb(R, G, B)
- Range:
- 0–255 per channel
- Zoo tshaj rau:
- code, canvas, transparency with rgba()
Dab tsi yog HEX?
A HEX code is a six-digit hexadecimal number that stores the red, green and blue channel of a color behind a leading #. Each pair of digits covers one channel, from 00 (none) to FF (full), which gives the same 16.7 million colors as RGB in a much shorter notation. HEX is the default in CSS, design tools and brand guidelines.
- Syntax:
- #RRGGBB
- Range:
- 00–FF per channel
- Zoo tshaj rau:
- CSS, design handoff, brand guidelines
RGB rau HEX daim ntawv reference
Cov xim CSS feem ntau, hloov los ntawm RGB rau HEX.
| Xim | RGB | HEX |
|---|---|---|
| black | rgb(0, 0, 0) | #000000 |
| white | rgb(255, 255, 255) | #FFFFFF |
| red | rgb(255, 0, 0) | #FF0000 |
| lime | rgb(0, 255, 0) | #00FF00 |
| blue | rgb(0, 0, 255) | #0000FF |
| yellow | rgb(255, 255, 0) | #FFFF00 |
| orange | rgb(255, 165, 0) | #FFA500 |
| teal | rgb(0, 128, 128) | #008080 |
| purple | rgb(128, 0, 128) | #800080 |
| gray | rgb(128, 128, 128) | #808080 |