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
Release: 2024-11-28 00:39:11
Original
713 people have browsed it

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

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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template