It is a simple hack also known as the ‘* property hack’. It is useful when it comes to dealing with the older versions of Internet Explorer (i.e. IE6 and IE7). When we add * before any property name in CSS, it targets IE 7 and below version of IE browsers and reflects when loading the same CSS on the browser while it acts as junk for all other browsers including IE 8 and above.
Note: We can use underscore (_) for IE6 and the star (*) for IE7. Add _ or * in front of a CSS property when required.
color: blue; /* all browsers */ *color: blue; /* IE7 and below */ _color: blue; /* IE6 and below */
Below example illustrate the star-preceded property in CSS:
Example: In this example, we will see how an element preceding with a * behaves differently for different versions in IE. We can see that for element h1 we have added the property color beginning with a *.
Note: It is a kind of bug and it will only works for IE7 and below.
- Output For IE 7 and below: We can see that our h1 property with text GeeksforGeeks is green in color thus, *property name is excepted by this browser version.
- Output For IE 8 and above: We can see that our h1 property with text GeeksforGeeks is black in color showing that *property name is treated as junk in browser IE 8 and above.
- How to use a not:first-child selector in CSS?
- What is the best way to include CSS file? Why use @import?
- Use of :even and :odd pseudo-classes with list items in CSS
- What is the use of asterisk (*) selector in CSS ?
- How to use text as background using CSS ?
- CSS | transition-property Property
- How to override the CSS properties of a class using another CSS class ?
- Difference between bootstrap.css and bootstrap-theme.css
- How to use SQLMAP to test a website for SQL Injection vulnerability
- How to use animation on favicon image ?
- Python | Use of __slots__
- Use of Shopify Apps
- How to use mailto in HTML ?
- How to use jQuery to Search and Replace HTML elements?
- What is the use of the @ symbol in PHP?
- How to use a switch case 'or' in PHP?
- Use of FLAG in programming
- How to use Array.BinarySearch() Method in C# | Set -2
- What is the use of “=>” symbol in PHP ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.