Home > Web Front-end > CSS Tutorial > What are CSS Star Property Hacks and How Do They Work?

What are CSS Star Property Hacks and How Do They Work?

Barbara Streisand
Release: 2024-12-05 03:41:09
Original
743 people have browsed it

What are CSS Star Property Hacks and How Do They Work?

What are the Star Property Hacks in CSS?

In CSS, a star-preceded property is known as a "star property hack." This technique is primarily used to target older versions of Internet Explorer browsers, specifically IE6 and IE7.

Consider the following CSS rule set:

div.with-some-class {
    display:block;                   
    margin:0;
    padding:2px 0 0 0;
    *padding:1px 0 0 0;
    font-size:11px;   
    font-weight:normal;
    *line-height:13px;
    color:#3D9AD0;
}
Copy after login

In this example, the asterisk (*) before the padding and line-height properties are star property hacks. They allow you to specify different values for these properties specifically in older versions of Internet Explorer.

The "star property hack" works because IE ignores the junk character preceding the property. In this case, the asterisk (*) is considered junk by IE, so the following CSS rule is applied to older IE browsers:

div.with-some-class {
    display:block;                   
    margin:0;
    padding:1px 0 0 0;
    line-height:13px;
    font-size:11px;   
    font-weight:normal;
    color:#3D9AD0;
}
Copy after login

This hack is particularly useful when you need to apply different styles to specific browsers or versions of browsers. However, it is important to note that star property hacks are not supported in modern browsers, so they should only be used when necessary.

The above is the detailed content of What are CSS Star Property Hacks and How Do They Work?. 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