Validate that a string is a safe CSS color value.
Accepts named colors, hex notation (#RGB, #RGBA, #RRGGBB, #RRGGBBAA), and functional notation (rgb(), rgba(), hsl(), hsla()) with strictly numeric arguments.
#RGB
#RGBA
#RRGGBB
#RRGGBBAA
rgb()
rgba()
hsl()
hsla()
Rejects anything else -- including semicolons, url(), expression(), and any other pattern that could be used for CSS injection.
url()
expression()
The CSS color value to validate.
true if the value is a recognized safe color format.
true
Validate that a string is a safe CSS color value.
Accepts named colors, hex notation (
#RGB,#RGBA,#RRGGBB,#RRGGBBAA), and functional notation (rgb(),rgba(),hsl(),hsla()) with strictly numeric arguments.Rejects anything else -- including semicolons,
url(),expression(), and any other pattern that could be used for CSS injection.