Welcome to WebmasterWorld Guest from 54.163.129.96

Forum Moderators: not2easy

Message Too Old, No Replies

What is meant * {} in CSS?

     
10:29 am on Dec 27, 2011 (gmt 0)

New User

5+ Year Member

joined:June 16, 2011
posts: 5
votes: 0


What is meant


*
{...}


in CSS file.
11:36 am on Dec 27, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


The * is the universal selector; it matches any element. So your example will apply the style rule to every element.
11:40 am on Dec 27, 2011 (gmt 0)

New User

5+ Year Member

joined:June 16, 2011
posts: 5
votes: 0


Thanks.
10:02 pm on Dec 27, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13266
votes: 363


OK, now I'm curious. Are there any circumstances where you would legitimately do this? As opposed to, say,
html {blahblah}
and letting everyone else inherit from there. Are we talking size, color, what?
10:38 pm on Dec 27, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Aug 9, 2008
posts: 961
votes: 0


he he, one of those questions where the answer begs the question ;).

Not all properties inherit by default Appendix F. Full property table [w3.org], and not all versions would apply inherit even if explicitly set. Hence the popularity of variations of:
* {
margin:0;
border:0;
}

But as the universal selector is very inefficient I think the real message in the question really is to ask if it is the best way to achieve the desired outcome. Legimate? I guess that depends on the code-complexity/code inefficiency trade-off

edit reason
Clarify