Home >Web Front-end >CSS Tutorial >Why Are Asterisks Invalid in CSS Property Names?

Why Are Asterisks Invalid in CSS Property Names?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-28 07:28:11447browse

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!

Statement:
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