The rules to be a valid hexadecimal code are:
- It should start from ‘#’ symbol.
- It should be followed by the letters from a-f, A-F and/or digits from 0-9.
- The length of the hexadecimal color code should be either 6 or 3, excluding ‘#’ symbol.
The rules to be a valid hexadecimal code are: