Home >Web Front-end >CSS Tutorial >Why Are Asterisks Invalid in CSS Property Names?
Asterisks in CSS Property Names: A Syntax Oddity
Beyond their familiar role in CSS selectors, asterisks have a peculiar usage in property names that warrants attention. While asterisks are often associated with universal selectors, they play a different part in property names.
An asterisk appearing in a CSS property name, as seen in the example code.yui-button .first-child{*display:inline-block;}, is a syntax error. This anomaly renders the property name invalid, preventing it from being correctly parsed.
However, due to specific browser bugs, the asterisk in a property name may sometimes be ignored. This effectively applies the property only to browsers exhibiting that bug, such as Internet Explorer 7 (IE7).
It is important to note that while this behavior may appear convenient, it is generally not recommended. Instead, conditional comments should be utilized for conditionally applying CSS styles to specific browsers rather than relying on this error behavior.
The above is the detailed content of Why Are Asterisks Invalid in CSS Property Names?. For more information, please follow other related articles on the PHP Chinese website!