Home >Web Front-end >CSS Tutorial >Why Does an Asterisk in a CSS Property Name (*display) Cause a Parsing Exception?

Why Does an Asterisk in a CSS Property Name (*display) Cause a Parsing Exception?

DDD
DDDOriginal
2024-11-28 00:39:11776browse

Why Does an Asterisk in a CSS Property Name (*display) Cause a Parsing Exception?

Parsing Exception: Asterisk in CSS Property Name

This question delves into the peculiar behavior of an asterisk (*) within a CSS property name, a feature notably absent in CSS selectors.

An example provided by the user showcases '*display' in a CSS rule:

.yui-button .first-child
{
    display:block;
    *display:inline-block;
}

Parsing Error

Contrary to expectations, '*display' is not a valid property name in CSS. Its presence renders the property invalid and aborts its parsing.

Browser Bugs and Quirks

However, due to historical browser quirks, some browsers (most prominently IE7) may overlook this invalidity and implement the rule as if '*display' were legitimate.

Avoidance and Best Practices

For cross-browser compatibility and to maintain code quality, it is highly recommended to avoid using an asterisk in property names. Instead, conditional comments should be employed to target specific browsers.

The above is the detailed content of Why Does an Asterisk in a CSS Property Name (*display) Cause a Parsing Exception?. 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