Quote:
Originally Posted by dgatwood
The approach I would tend to take is this:
1. If the user doesn't request a style override, use the publisher's style as-is.
2. If the user asks for a typical style override, inject a new style tag after the last one in the document, then walk each stylesheet in the order in which they appear (not including the one you just inserted). For each CSS rule in the book's stylesheets:
a. Create a new rule set in your custom stylesheet with the same selector.
b. Inspect each declaration within that rule, and if there is a conflicting declaration in the book's stylesheet that is not marked !important, insert your own declaration inside the rule set you just created.
c. If there is a conflicting declaration that is marked !important, don't try to override it.
Repeat until you have processed every stylesheet in the book.
3. If the user asks for a "sudo" style override, either disable the book's stylesheet outright and substitute your own, or follow the steps for #2, but override the !important styles, too. Please be judicious in deciding when it is appropriate to do this, though. This really only makes sense if you're basically overriding everything—font face, font size, line height, margins (and particularly negative margins), padding, etc. and setting everything to the defaults. If you leave almost any book-specific styling in place, you'll almost invariably break things.
|
Excellent answers I'm getting! Thank you.
Question: wouldn't number 2 override headers? Would you say it's a good idea for my selector for the user's font size target paragraph tags, instead of body?