A hex color code is a six-digit hexadecimal number that represents colors in the RGB color model. It is the most common way to specify colors in HTML and CSS, using the format #RRGGBB where each pair represents red, green, and blue intensity.
Hex color codes start with # followed by six hexadecimal digits (0-9 and A-F). The first two digits represent red intensity, the middle two green, and the last two blue. For example, #FF0000 is pure red (maximum red, no green or blue), #00FF00 is green, #0000FF is blue, #FFFFFF is white, and #000000 is black.
Each color channel (red, green, blue) is represented by two hex digits ranging from 00 (0 in decimal, minimum intensity) to FF (255 in decimal, maximum intensity). This gives 256 possible values per channel, resulting in 256 = 16,777,216 total colors. Shorthand notation uses three digits (#RGB expands to #RRGGBB) when each pair has matching digits.
Split #RRGGBB into three pairs: RR (red intensity 00-FF), GG (green intensity 00-FF), BB (blue intensity 00-FF). FF is maximum, 00 is minimum. #FF0000 is full red, #008000 is medium green.
Hex (#FF0000) and rgb (rgb(255, 0, 0)) represent the same colors. Hex is more compact, while RGB is more readable for understanding channel values. They are interchangeable in CSS.
Six-digit hex (standard) represents 16,777,216 colors (256 per channel). Eight-digit hex adds alpha transparency for 256 levels of opacity.