Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css: the meaning of * mark

Tags:

css

Can you tell me what's the meaning of this:

*{
   margin:0 auto;
   padding:0;
  }
like image 314
klox Avatar asked Jul 29 '10 03:07

klox


2 Answers

that is a wildcard that will effect all the child nodes of the document node. Every DOM element basically on the page. You always wanna put that at the beginning of the CSS otherwise it will overrule all the other rules above it.

I recommend using css reset style sheets. One of the best is on Yahoos YUI project, google I believe also has it. This will do all the initializing of the css and reseting everything for every browser so everything you do will look the same regardless of the user agent. the reason I really recommend this for you is because you are a beginner and you will be banging your head against the wall like I did when css first came out and none of these were available. You can also jump into fun things rather than dealing with these sort of rules. It will also speed the performance if you link to it on google or yahoos server. this is totally legal and thats what they are serving it for.

like image 106
Neo Avatar answered Sep 30 '22 18:09

Neo


* matches everything. That particular snippet is setting the default padding for everything to 0,0,0,0 and the default margins to 0, auto (that is, vertical margins are 0, horizontal margins are "auto").

like image 39
Dean Harding Avatar answered Sep 30 '22 18:09

Dean Harding