Jitendra Vyas
Jitendra Vyas

Reputation: 152627

Are both CSS declaration same, in effect?

Are

    html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, 
blockquote, img, strong, dl, dt, dd, 
ol, ul, li, fieldset, form {background:transparent;}

and

body {background:transparent;}

same thing?

Upvotes: 2

Views: 97

Answers (5)

Ritesh Choudhary
Ritesh Choudhary

Reputation: 782

no this is not same because


html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, img, strong, dl, dt, dd, ol, ul, li, fieldset, form {background:transparent;}

has separate style background:transparent


but in case of

body {background:transparent;}

inherited style background:transparent

Upvotes: 0

bobince
bobince

Reputation: 536339

They're the same thing in as much as none of those elements have backgrounds anyway.

They'd only have any effect if they were overriding backgrounds set by previous rules, either earlier in your own stylesheet, or in a user's custom stylesheet.

I really wouldn't bother. It's resetting gone mad.

Upvotes: 0

Gabriele Petrioli
Gabriele Petrioli

Reputation: 195972

As far as body is concerned yes..

But the first case also makes background transparent all those other tags..

if you are looking for a shorthand then you could use the (warning:all inclusive)

body, body *{background:transparent}

Upvotes: 1

theorise
theorise

Reputation: 7425

No, body {} will just do body and no child elements. html{} is also the parent of body{}

This would select all of the children of the html element, although I don't think it would effect things such as h1, h2 etc, as they would be children of child elements etc.

html > * {background:transparent;}

Every reset stylesheet I have seen does what you have done in your first block of CSS. I think it is the only way to make sure you have selected all of the elements on the site.

Upvotes: 3

Adam Lukaszczyk
Adam Lukaszczyk

Reputation: 4926

no becouse in second you define only background for body, so all the rest stay without changes

Upvotes: 2

Related Questions