
On 11/6/2012 Lee Passey wrote various examples of using the style atribute, for example: <h4 style="page-break-before:always><br />Chapter One</h4> At the end of the append, he wrote:
On the other hand, <div class="center"> with a corresponding CSS of div.center{ text-align:center; } doesn't make sense to me. The <div> isn't a "center", and there is no reason you would want to alter its presentation. If it's supposed to be centered, and there is no real presentational alternative, just put the styling right on the element to be styled.
Personally I rather like this idea as it neatly gets me out of another problem I thought was unavoidable, namely the need to have a whole series of classes in a generic css file which only differ by a parameter value, for example: /* - - - Left margins */ div.margin-left-1 {margin-left: 0.5em} div.margin-left-2 {margin-left: 1em} div.margin-left-3 {margin-left: 1.5em} div.margin-left-5 {margin-left: 2.5em} div.margin-left-7 {margin-left: 3.5em} div.margin-left-10 {margin-left: 5em} div.margin-left-15 {margin-left: 7.5em} div.margin-left-20 {margin-left: 10em} div.margin-left-25 {margin-left: 12.5em} (What would be nice is to have parameters in class definitions to get round this, hypothetically somewhat as follows: <* - - - Left margins */ div.margin-left(n number) {margin-left: n em} Syntactically this is nonsense, but I hope it is reasonably clear what I would like to be able to do.) Lee's scheme seems to offer another way round this problem, namely that one would merely at the appropriate point in the text mark up with <div style="margin-left: n em">text content</div> thus not needing any css classes at all. However the reason I didn't go this way to start with is that use of the style attribute appears to be deprecated in both the epub 2 and epub 3 specifications. I assume this means that sooner or later the standard will drop support for it. Have I misunderstood? Bob Gibbins

On 11/7/2012 1:49 PM, Robert Gibbins wrote:
However the reason I didn't go this way to start with is that use of the style attribute appears to be deprecated in both the epub 2 and epub 3 specifications. I assume this means that sooner or later the standard will drop support for it. Have I misunderstood?
Probably. The code word we are dealing with here is "inline style." In ePub 2 there was a single comment stating, "This specification supports the inline style attribute (deprecated), the XHTML style element, and externally linked (via link elements or the xml-stylesheet processing instruction) style sheets." However, there was never any explicit declaration that inline styles were definitively deprecated. In early drafts of the ePub 3 specification it included the phrase, "Content Documents, like any HTML documents, may reference style sheets or include inline style information." That phrase was later removed from the specification, and no further reference to inline styles was included. Instead, the ePub 3 specifications provides, "Unless otherwise specified, this specification inherits all definitions of semantics, structure and processing behaviors from the [HTML5] specification." The style attribute is still part of HTML5, so I think it is safe to say that inline styles are still an accepted part of ePub. From a practical point of view, every ePub user agent I am aware of that can parse CSS style sheets (including internal style sheets) can also parse and apply inline styles. I'm sure this is because virtually every ePub user agent wraps an existing HTML rendering engine. Extracting inlines style and placing them into a style sheet is a rather trivial programming effort--HTML Tidy does a very similar thing right now. If ePub ever /does/ deprecate inline styles, I'll volunteer to write the program to transform inline styles into an internal style sheet.

On 11/7/2012 1:49 PM, Robert Gibbins wrote:
Lee's scheme seems to offer another way round this problem, namely that one would merely at the appropriate point in the text mark up with <div style="margin-left: n em">text content</div> thus not needing any css classes at all.
BTW, your margin example is not a good one. If you're changing margins you'd better have a good reason for doing so, other than simply because you think it looks better that way, in which case the right thing to do is to classify the <div> by the reason rather than trying to style it. E.g.: div.newspaper { margin-left: 2em; } div.toc { margin-left: 0em; } div.signinbarbershopwindow { margin-left: 3em } If you don't have a semantic reason for changing margins, don't do it. Only use inline styles on elements when there is really no alternative, and no one would want it done otherwise. If there's /any/ chance that a reader would disagree with your choice of style, put it in an external style sheet.
participants (2)
-
Lee Passey
-
Robert Gibbins