Forum Moderators: not2easy
The order is important here--rules read last take precedence. Your "new" style rules should override the old ones.
If you set the ID of your BODY tag on each page, you can then target elements on each page in the style sheet
This could be a very helpful solution, though I'll admit at first glance your example made me think it could be quite cumbersome, requiring a long list of ID's (one for each page, or at least each page that differed from the default style(s)).
But, in fact, since the ID selector can be used once per page, you should be able to reuse the same ID across many pages, and use a very limited number. In that case I would think you would want to avoid a pattern like "#page1,#page2, etc" and use something more generic.
I'm wondering, though...would that make it any different from using CLASS? And is there any reason you could not simply assign the style(s) to a CLASS and use that in a BODY tag on some pages, and in a block tag (e.g., DIV) on other pages, as needed?
(Theoretically, it seems that should work. But does the BODY tag accept the CLASS selector? And if it does, why do we create DIV blocks that include an entire page when we could accomplish the same thing in the BODY tag?)
But does the BODY tag accept the CLASS selector?
Yes, the body tag can have a class applied to it, no problem. In this case, I agree with you that a class attribute would be more appropriate.
And if it does, why do we create DIV blocks that include an entire page when we could accomplish the same thing in the BODY tag?
Because people don't realise the above! Divs are generally over-used and make for bloated code, and can often be removed and the styles applied to other tags.