Common use cases
- ✓Theme and design-token validation
- ✓Color-picker form checks
- ✓CSS configuration imports
Validate CSS hexadecimal color notation with a leading # and 3, 4, 6, or 8 hexadecimal digits. This covers short and long RGB forms plus the short and long forms that include an alpha channel.
^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$Flags: i
Enter one value per line. Each line is tested against the whole-string pattern using the browser JavaScript RegExp engine.
#fff#0f08#FF5733#336699ccfff#12#12345#ggggggCSS hex colors start with # and use exactly 3, 4, 6, or 8 hexadecimal digits. The four- and eight-digit forms include alpha; other lengths should be rejected.
#fff#0f08#FF5733#336699ccfff#12#12345#ggggggThey add an alpha component to the short and long RGB forms. The fourth or eighth byte-pair position represents opacity.
No. Hexadecimal digits A–F can be uppercase or lowercase, so the page uses case-insensitive matching.
No. It validates hexadecimal color notation only. Named colors, rgb(), hsl(), and other CSS color syntaxes are separate formats.
Move from a live JavaScript regex test to capture-group inspection, flag behavior, literal escaping, focused pattern references, and debugging guides without treating each regex task as an isolated page.