Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 04-14-2013, 03:59 PM   #1
travger
Evangelist
travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.
 
travger's Avatar
 
Posts: 469
Karma: 270594
Join Date: Aug 2010
Device: palm tx, Windows XP, Windows7
I made a discovery, but should I use it?

I found that an element can have more than one class.

Like, when all paragraphs are indented and I want to remove indent from first paragraph then it's enough to add "first" to the existing p class
Code:
<p class="calibre1 first">
and
Code:
.first {text-indent:0}
to the css.

Result looks the same if I copy the normal paragraph class, change text-indent to 0 (and it's name) and then change p class in every first paragraph to the new name.

Or if I want one p to be exactly like others, only little bit smaller. Why should I create new class with only one difference from previous?

But is it safe to use, can most/all readers cope with it? If yes, then why is it so seldom used? Or is there some other reason why I see (mostly) that every h or p has only one class; maybe it won't convert well?
travger is offline   Reply With Quote
Old 04-15-2013, 01:07 AM   #2
Turtle91
Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 1,252
Karma: 11014344
Join Date: Dec 2012
Location: Altus, Oklahoma today
Device: iPhone 6/5/iPad 1,2 & Air/Surface Pro/Kindle PW
I occasionally use multiple classes like this and have not had any problems....however, my testing has been a little limited. Marvin, epubreader, a little kindle and ade to name a couple.

I would recommend NOT using conflicting classes though - indent and non-indent - that seems to be asking for issues not to mention slightly bloating the code. I would use classes with different functionality.
For example:
.ctr {text-align:center}
.spacer {margin-top:2em; margin-bottom:2em}

<p class="ctr spacer">


Granted, both of those could be defined in a single class, but it is just an example of not having conflicting styling.

Cheers!
Turtle91 is offline   Reply With Quote
 
Advertisement
Old 04-15-2013, 03:04 AM   #3
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,216
Karma: 109735549
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-300, PRS-T1
You can and 'should' use it. It would minimize the number of classes in a stylesheet. Remember that it is cascading. The second class you will use, will add to the first one. Or at least it should according to the specs. That also means, that if there are conflicting settings, the second one would be the one used.

Example:
.initial {text-indent: 0; font-weight: bold;}
.second {font-weight: normal;}

If you now would assign it to a tag, e.g.<p class="initial second">, the text would not have an indent and normal font-weight. Of course this is just an example...

I do recommend always to check the result, since the cascading factor can sometimes surprise you.
Toxaris is offline   Reply With Quote
Old 04-15-2013, 04:15 AM   #4
travger
Evangelist
travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.
 
travger's Avatar
 
Posts: 469
Karma: 270594
Join Date: Aug 2010
Device: palm tx, Windows XP, Windows7
Thank you for the responses.

I do check in Sigil. If I ever read that epub outside Calibre and find surprises, I can open it up again.

Bloating the code is good point, I'll keep it in mind.

Mostly I feel the urge just to add a class when the stylesheet is too long anyway or I want some specific paragraph to look little different.
travger is offline   Reply With Quote
Old 04-15-2013, 05:19 AM   #5
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,216
Karma: 109735549
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-300, PRS-T1
Especially in the last case you describe is one of the use cases for me at least.
Toxaris is offline   Reply With Quote
Old 04-15-2013, 07:26 AM   #6
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 77,906
Karma: 68014019
Join Date: Nov 2006
Location: UK
Device: Kindle Voyage, iPad Air 2, iPhone 6
Absolutely - that's exactly the way to do it. That's why they're called cascading style sheets, because each new style modifies the previous ones. If you have a "paragraph" style, which indents paragraphs, and you want a style for "initial paragraph" with no indent, simply specify the lack of indentation as a modification to the normal paragraph style; don't duplicate the entire style.
HarryT is offline   Reply With Quote
Old 04-15-2013, 07:39 AM   #7
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 46,931
Karma: 160870417
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
Quote:
Originally Posted by HarryT View Post
Absolutely - that's exactly the way to do it. That's why they're called cascading style sheets, because each new style modifies the previous ones. If you have a "paragraph" style, which indents paragraphs, and you want a style for "initial paragraph" with no indent, simply specify the lack of indentation as a modification to the normal paragraph style; don't duplicate the entire style.
This is slightly different from the use of two style sheets on the same element. The cascading bit means that an element inherits all applicable styles, with the specific overriding the generic.

So a paragraph <p class="first"> inherits any style set on body, any enclosing div or other block, the generic paragraph style definition and only then the class "first".
pdurrant is offline   Reply With Quote
Old 04-15-2013, 07:41 AM   #8
exaltedwombat
Guru
exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.
 
Posts: 608
Karma: 1771606
Join Date: Nov 2011
Device: none
What about

h1 + p {text-indent:0;}

in the stylesheet?
Does this method of cancelling the indent of a first paragraph (i.e. one following a chapter heading using <h1>) cause problems in any standard reader?
exaltedwombat is offline   Reply With Quote
Old 04-15-2013, 07:56 AM   #9
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 4,216
Karma: 109735549
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-300, PRS-T1
None in the ones I know. I actually use that.
Toxaris is offline   Reply With Quote
Old 04-15-2013, 09:49 AM   #10
Turtle91
Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 1,252
Karma: 11014344
Join Date: Dec 2012
Location: Altus, Oklahoma today
Device: iPhone 6/5/iPad 1,2 & Air/Surface Pro/Kindle PW
Quote:
Originally Posted by exaltedwombat View Post
What about

h1 + p {text-indent:0;}

in the stylesheet?
Does this method of cancelling the indent of a first paragraph (i.e. one following a chapter heading using <h1>) cause problems in any standard reader?
+1 Toxaris

I use it all the time. There are very few paragraphs that need a special class when you use techniques like this - that's a good thing!

I use multiple's like this:
p.ChDiv + p, blockquote + p, h2 + p, div.bannerlist + p, img + p, table + p {text-indent:0}
Turtle91 is offline   Reply With Quote
Old 04-15-2013, 09:59 AM   #11
Turtle91
Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 1,252
Karma: 11014344
Join Date: Dec 2012
Location: Altus, Oklahoma today
Device: iPhone 6/5/iPad 1,2 & Air/Surface Pro/Kindle PW
I also combine that with pseudo elements to style first paragraphs in the chapter.

h2 + p {text-indent:0; font-size:1em; line-height:1em}
h2 + p:first-letter {font-family:"Monotype Corsiva", "cursive"; font-size:3em; font-weight:bold; font-style:italic;float:left;margin-right:.1em; margin-bottom:.2em}
h2 + p:first-line {font-variant:small-caps; font-size:1.15em}

<h2>Chapter One</h2>
<p>This is first paragraph text.</p>

That gives a nice drop cap for the first letter and the first line (no matter what the width of the display) is in small caps.

I use that on my personal books because the reading app I use is mostly spec compliant...so it displays properly. Some non-compliant software, such as ADE, don't support pseudo elements, but they degrade gracefully. If you are making a commercial book then you would need to use workarounds to get the same effect.

Cheers,
Turtle91 is offline   Reply With Quote
Old 04-15-2013, 10:02 AM   #12
pdurrant
The Grand Mouse 高貴的老鼠
pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.pdurrant ought to be getting tired of karma fortunes by now.
 
pdurrant's Avatar
 
Posts: 46,931
Karma: 160870417
Join Date: Jul 2007
Location: Norfolk, England
Device: Kindle Voyage
It's annoying that ADE doesn't support pseudo elements, since it's part of the ePub 2.0 spec, re-confirmed in the 3.0 spec.
pdurrant is offline   Reply With Quote
Old 04-15-2013, 01:07 PM   #13
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 45,410
Karma: 32620990
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, Sony PRS-650, Sony PRS-T1, nook STR, iPad 4, iPhone 5
Quote:
Originally Posted by pdurrant View Post
This is slightly different from the use of two style sheets on the same element. The cascading bit means that an element inherits all applicable styles, with the specific overriding the generic.

So a paragraph <p class="first"> inherits any style set on body, any enclosing div or other block, the generic paragraph style definition and only then the class "first".
If goes body, p, first in that order.

I set p to what most p will be so I can get rid of things like <p class="para">. makes the code look that bit neater and the ePub smaller.
JSWolf is offline   Reply With Quote
Old 04-15-2013, 02:29 PM   #14
travger
Evangelist
travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.travger ought to be getting tired of karma fortunes by now.
 
travger's Avatar
 
Posts: 469
Karma: 270594
Join Date: Aug 2010
Device: palm tx, Windows XP, Windows7
I must remember that h+p trick. I actually knew it, but somehow never think about it when I should. Mostly I'm fixing something already formatted and it seems easier to slip in another class.

I'm afraid to use Replace All on those p class="calibre1" kind of paragraphs. Logic says that it should be safe, but I still can't feel sure there is not anything hidden. Maybe when I have few years of experience ... or like some book very-very much. Now it takes me whole day to check all the classes and figure out what they do.
travger is offline   Reply With Quote
Old 04-15-2013, 09:09 PM   #15
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 19,812
Karma: 19044546
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Astak Pocket Pro, K4NT,Galaxy Tab 2
Quote:
Originally Posted by travger View Post
I must remember that h+p trick. I actually knew it, but somehow never think about it when I should. Mostly I'm fixing something already formatted and it seems easier to slip in another class.

I'm afraid to use Replace All on those p class="calibre1" kind of paragraphs. Logic says that it should be safe, but I still can't feel sure there is not anything hidden. Maybe when I have few years of experience ... or like some book very-very much. Now it takes me whole day to check all the classes and figure out what they do.
Replace the whole tag (<p class="calibre1">) with <p> to be safe and avoid any other usage combinations.
theducks is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Touch My home-made KT case made out of a real book vferdman Kobo Reader 6 02-18-2012 12:05 AM
Clovis Killer Discovery kennyc Lounge 67 03-30-2011 07:00 AM
Drift: A Novel of Discovery Drift Writers' Corner 0 09-17-2009 02:28 PM


All times are GMT -4. The time now is 10:50 PM.


MobileRead.com is a privately owned, operated and funded community.