Home > Web Front-end > CSS Tutorial > Why Are Asterisks Used as Prefixes in Some CSS Properties?

Why Are Asterisks Used as Prefixes in Some CSS Properties?

Linda Hamilton
Release: 2024-12-18 05:23:09
Original
696 people have browsed it

Why Are Asterisks Used as Prefixes in Some CSS Properties?

Using Asterisk Prefix in CSS: A Browser-Specific Hack

The Yahoo CSS reset includes the following lines:

body {
  font:13px/1.231 arial,helvetica,clean,sans-serif;
  *font-size:small;
  *font:x-small;
}
Copy after login

The presence of asterisks before certain CSS properties raises the question of their purpose.

Answer:

The asterisks serve as a browser-specific CSS hack, primarily targeting Internet Explorer versions 7 and below. This hack takes the following form:

*property: value
Copy after login

While Internet Explorer 7 has addressed issues related to underscores and hyphens preceding property names, it continues to treat non-alphanumeric prefixes differently. Consequently, by adding an asterisk immediately before a property name, developers can ensure that the property is applied in IE, but not in other browsers.

It's important to note that this hack relies on invalid CSS. Moreover, future updates to the CSS specifications may render it ineffective. Therefore, it should be used with caution and only as a temporary solution.

The above is the detailed content of Why Are Asterisks Used as Prefixes in Some CSS Properties?. 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