Skip to main content
edited tags
Link
Michael Durrant
  • 13.4k
  • 5
  • 38
  • 63
Tweeted twitter.com/#!/StackProgrammer/status/275268625458405376
added 145 characters in body
Source Link
Michael Durrant
  • 13.4k
  • 5
  • 38
  • 63

Applying styles to the body tag will be applied to the whole page, so

body { font-family: Verdana }

will be applied to the whole page. This could also be done with

* {font-family: Verdana} 

which would apply to all elements and so would seem to have the same effect.

I understand the principle that in the first instance the style is being applied to one tag, body for the whole page whereas in the second example the font is being applied against each individual html elements. What I am asking is what is the practical difference in doing that, what are the implications and what is a reason, situation or best practice that leads to using one over another.

One side-effect is certainly speed (+1 Rob). I am most interested in the actual reason to choose one over the other in terms of functionality.

Applying styles to the body tag will be applied to the whole page, so

body { font-family: Verdana }

will be applied to the whole page. This could also be done with

* {font-family: Verdana} 

which would apply to all elements and so would seem to have the same effect.

I understand the principle that in the first instance the style is being applied to one tag, body for the whole page whereas in the second example the font is being applied against each individual html elements. What I am asking is what is the practical difference in doing that, what are the implications and what is a reason, situation or best practice that leads to using one over another.

Applying styles to the body tag will be applied to the whole page, so

body { font-family: Verdana }

will be applied to the whole page. This could also be done with

* {font-family: Verdana} 

which would apply to all elements and so would seem to have the same effect.

I understand the principle that in the first instance the style is being applied to one tag, body for the whole page whereas in the second example the font is being applied against each individual html elements. What I am asking is what is the practical difference in doing that, what are the implications and what is a reason, situation or best practice that leads to using one over another.

One side-effect is certainly speed (+1 Rob). I am most interested in the actual reason to choose one over the other in terms of functionality.

Source Link
Michael Durrant
  • 13.4k
  • 5
  • 38
  • 63

css - use universal '*' selector vs. html or body selector?

Applying styles to the body tag will be applied to the whole page, so

body { font-family: Verdana }

will be applied to the whole page. This could also be done with

* {font-family: Verdana} 

which would apply to all elements and so would seem to have the same effect.

I understand the principle that in the first instance the style is being applied to one tag, body for the whole page whereas in the second example the font is being applied against each individual html elements. What I am asking is what is the practical difference in doing that, what are the implications and what is a reason, situation or best practice that leads to using one over another.