Forum Moderators: not2easy

Message Too Old, No Replies

Asterisk Selector Question

         

RayH

5:43 pm on Jul 9, 2010 (gmt 0)

10+ Year Member



Hi,

I understand how to use an asterisk as a universal selector however when I was viewing my sites CSS I discovered this.

#header ul.toolbar li {
border-right: 2px solid #ad0304;
margin-right: 6px;
padding-right: 6px;
*margin-right: 6px;
*padding-right: 4px;
}


Can any one explain what the * does in this instance?

Fotiman

6:08 pm on Jul 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This is a "Star Hack" for IE. IE versions 7 and lower will recognize these rules. So in this example, the padding-right is being set to 6px for all browsers, and then IE7 and under will set it to 4px instead. In this particular case, margin-right is also being set but the IE hack is not actually needed since the value is the same as the previous margin-right value.

RayH

6:21 pm on Jul 9, 2010 (gmt 0)

10+ Year Member



Wow that was fast thanks!

That was my first post and I am really impressed by the response time and the clarity of your answer.

Thanks again!

Fotiman

6:54 pm on Jul 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ah, I didn't even notice it was your first post, else I would have said Welcome to WebmasterWorld! :) Glad you found that useful.

Note, you might also notice cases where an underscore is used. As in:

padding-right: 6px;
*padding-right: 4px;
_padding-right: 2px;

The underscore version is recognized by IE6 and under, but not by IE7. So in this example, you'd be defining 6px padding for all browsers, then 4px padding for IE7 and under, then 2px padding for IE6 and under. Note, the order that you define them in is important.