Asterisks in CSS Property Names
Beyond their role in CSS selectors, asterisks can also appear in property names. However, in this context, their presence is not benign.
An example of an asterisk in a CSS property name is the following code from YUI:
.yui-button .first-child { display:block; *display:inline-block; }
The *display property is invalid and effectively renders the property name useless. This is because it constitutes a syntax error in CSS.
Despite this, browser quirks have sometimes led to asterisk-laden property names being ignored. This had the unintended effect of causing the property to apply only to browsers with specific bugs, such as Internet Explorer 7.
In modern CSS practices, asterisks in property names are strongly discouraged. Instead, conditional comments should be used to target specific browsers with different styles. This approach is more reliable and maintainable than relying on outdated and potentially error-prone techniques.
The above is the detailed content of Why Are Asterisks in CSS Property Names a Bad Idea?. For more information, please follow other related articles on the PHP Chinese website!