Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the * do in CSS?

Tags:

css

What does the star do? What is it called? For me it is some kind of wild card. What is it called so I can read about it?

#div {
  *zoom: 1; /*this ... *
   zoom : 1;
   display: inline;
   *display: inline; /*... and this, whats the difference? *
}

I know what this means (all elements):

* {
..css code
}
like image 436
pethel Avatar asked Apr 12 '13 07:04

pethel


People also ask

What does the * means in CSS?

The * means "all elements" (a universal selector), so we are setting all elements to have zero margins, and zero padding, thus making them look the same in all browsers.

What is the * class in CSS?

What is a CSS class? A CSS class is an attribute used to define a group of HTML elements in order to apply unique styling and formatting to those elements with CSS.

What does the asterisk mean in CSS?

The Universal Selector is the * in CSS. Literally the asterisk character. It is essentially a type selector that matches any type. Type meaning an HTML tag like <div> , <body> , <button> , or literally any of the others. A common use is in the universal reset, like this: * { margin: 0; padding: 0; }


1 Answers

In simple words, its the key to target css on different IE browser versions. It can also be called as an CSS Hack.

#div {
  *zoom: 1; /*Only works on IE7 and below*/
  zoom : 1;
  display: inline;
  *display: inline; /*Only works on IE7 and below*/
}

Means this CSS works only on IE7 and below. It's kind of a hack we can use to apply CSS on IE7 and below.

Here is how to target IE6, IE7, and IE8 Uniquely

#div{  
 color: red; /* all browsers, of course */  
 color : green\9; /* IE8 and below */  
 *color : yellow; /* IE7 and below */  
 _color : orange; /* IE6 */  
} 

CLICK HERE if you want learn more about browser specific CSS.

like image 99
Chamara Keragala Avatar answered Nov 22 '22 20:11

Chamara Keragala