Go directly to main content.

Overriding CSS

Project:EPUB Maintenance
Component:Open Publication Structure (OPS)
Category:task
Priority:normal
Assigned:HGardeur
Status:completed @ 2.0.1

Some of the EPUB reading systems available are capable of overriding CSS stylesheets to allow customization.

We need to define a better way for e-book designers and end users to coexist and allow designers to indicate which CSS properties can be overridden.

We might consider using "!important" (http://www.w3.org/TR/CSS2/cascade.html#important-rules) for this, or we could design our own syntax if we need something more advanced.

Description
Issue Id: 
9
Resolution: 

The OPS specification, section 3.0 (3.0: Style Sheets) is changed to include cascading, inheritance, selector specificity, and !important. Paragraph six:

"This specification assumes the use of selectors to be consistent with the definitions in the CSS2 Specification (see http://www.w3.org/TR/REC-CSS2/selector.html for details). For example, the rules for determining which of multiple rules are applied from a document’s style sheet are determined by the rules of inheritance, cascading and selector specificity (see http://www.w3.org/TR/CSS2/cascade.html for details)."

is replaced by:

"This specification assumes the use of selectors (see http://www.w3.org/TR/REC-CSS2/selector.html), cascade and inheritance (http://www.w3.org/TR/CSS2/cascade.html) to be consistent with the definitions in the CSS2 Specification .
For example, the CSS2 Specification defines the !important rules (http://www.w3.org/TR/CSS2/cascade.html#important-rules) to create a balance of power between author and user style sheets."

Comments

#1

I think !important is already part of the OPS spec (3.0 OPS Style Sheets):

"This specification assumes the use of selectors to be consistent with the definitions in the CSS2 Specification (see http://www.w3.org/TR/REC-CSS2/selector.html for details). For example, the rules for determining which of multiple rules are applied from a document’s style sheet are determined by the rules of inheritance, cascading and selector specificity (see http://www.w3.org/TR/CSS2/cascade.html for details)."

Since !important is an integral part of the cascade and selectors, I take it that that paragraph implies it must be supported. Is there additional functionality required that is not covered by !important?

As an action item, we could consider making the requirement of !important more explicit in the spec.

#2

It is indeed part of the specs but it's far from being explicit enough.
A lot of reading systems are currently overriding CSS elements, and I doubt that (any) content providers use !important.

Some general guideline in the specs about how reading systems should implement support for !important would also be very helpful.

Content providers could also provide examples that we could include in the future conformance tests.
Without these examples & tests, I really can't tell if support for !important will be enough to answer every use case or not.

Action items so far:

  • Support for !important should be more explicit
  • Guideline on how content providers and reading systems should implement support for !important
  • Create a list of examples provided by content providers
  • Test these examples

#3

The portion of the spec quoted in #1 is a little confusing.
It is mentioned that it is assumed that the use of selectors is consistent with the CSS2 Specification, but then the example talks about things that are not selectors nor selector related things.

Inheritance and cascading have to do with rules and property values, and !important is an identifier attached to a rule, not a selector.

So, I'd say we could clarify the section.

However I also think that we don't want to do anything with !important other than what is intended by CSS, so perhaps just a stronger/clearer declaration of support for the CSS2 approach to cascading, inheritance, selector specificity, and !important.

#4

I agree, it is confusing. As you said, the first sentence is about selectors, but the second sentence (an example) talks about entirely different things. I think what we really want to say is you have to implement the general rules of CSS per that spec. But in more spec-like language. I also agree that modifying the behavior of !important is a bad idea, but we might want to clarify exactly how it works in an epub environment.

#5

I certainly agree that we shouldn't change the behavior associated with !important, but we should clearly explain why it is important and how it should be implemented.
Do you approve the action items that I've listed above ?

#6

I think 1, 3 and 4 are fine (3 and 4 are part of making a validation suite for epub, which I think is on our list). I'm a bit concerned about 2. Unless there is something particularly tricky about implementing !important in epub (as opposed to css used in general web browsing) then I don't think we should add too many details.

#7

Status:future consideration» open

#8

Adobe SDK for EPUB implements user stylesheets, but not !important at this point. However we do consider it a part of the spec; it is pretty clear it is, I think - this is just a missing feature.

#9

Status:open» proposed resolution

#10

Status:proposed resolution» open

#11

Assigned to:Anonymous» HGardeur

#12

Instead of the portion of specs quoted in #1 we could use:
"This specification assumes the use of selectors (see http://www.w3.org/TR/REC-CSS2/selector.html), cascade and inheritance (http://www.w3.org/TR/CSS2/cascade.html) to be consistent with the definitions in the CSS2 Specification .
For example, the !important rules (http://www.w3.org/TR/CSS2/cascade.html#important-rules) to create a balance of power between author and user style sheets."

Do we only clarify or should we recommend using !important too ?

#13

Any feedback ?

#14

I've put the text into the resolution field, but made a slight change to HGardeur's text so that it becomes:

"This specification assumes the use of selectors (see http://www.w3.org/TR/REC-CSS2/selector.html), cascade and inheritance (http://www.w3.org/TR/CSS2/cascade.html) to be consistent with the definitions in the CSS2 Specification .
For example, the CSS2 Specification defines the !important rules (http://www.w3.org/TR/CSS2/cascade.html#important-rules) to create a balance of power between author and user style sheets."

#15

Status:open» proposed resolution

Sounds good to me.

#16

Status:proposed resolution» errata

 Moved to errata.

#17

Status:errata» completed @ 2.0.1

#19

I don't know if the preceding post is spam or not -- clever if it is -- our text with a "custom poker tables" embedded -- anyhow, the resolution is above in the resolution field. Also, this has been incorporated into the final 2.0.1 released specifications.

Valid XHTML 1.0!

Powered by Drupal, an open source content management system