Hex color codes are used in graphic design to specify the color of elements on a screen. They are a hexadecimal representation of a color, typically used in web design and digital graphics. Hex codes consist of six digits, each ranging from 00 to FF, representing the levels of red, green, and blue in the color.