Home > Web Front-end > CSS Tutorial > Why Are Asterisks in CSS Property Names a Bad Idea?

Why Are Asterisks in CSS Property Names a Bad Idea?

Barbara Streisand
Release: 2024-11-28 16:01:15
Original
631 people have browsed it

Why Are Asterisks in CSS Property Names a Bad Idea?

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;
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template