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 11-01-2015, 11:52 AM   #1
Arios
A curiosus lector!
Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.
 
Arios's Avatar
 
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
In CSS, * or body?

Hi guys,

Just by curiosity: in CSS is it better to use, for example:

Code:
* {
    margin: 0;
    text-indent: 0;
    padding: 0;
}
or put it in the the <body>:

Code:
body {
    margin: 0;
    text-indent: 0;
    padding: 0;
}
I mean, is it more in the semantic line or relevant/effective to use one instead of the other?

Incidentally what is the purpose of using, in an epub chapter, an empty <div>? A trick for some eReaders? You know, something like that:

Code:
<body>
<div>
  <h1>Title</h1>

  <p>blaba...</p>
</div>
</body>
Arios is offline   Reply With Quote
Old 11-01-2015, 12:54 PM   #2
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,411
Karma: 5625801
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Arios View Post
Hi guys,

Just by curiosity: in CSS is it better to use, for example:

Code:
* {
    margin: 0;
    text-indent: 0;
    padding: 0;
}
or put it in the the <body>:

Code:
body {
    margin: 0;
    text-indent: 0;
    padding: 0;
}
I mean, is it more in the semantic line or relevant/effective to use one instead of the other?
They are not the same. With

Code:
body {
    margin: 0;
    text-indent: 0;
    padding: 0;
}
only the "body box" will have those properties but with

Code:
* {
    margin: 0;
    text-indent: 0;
    padding: 0;
}
all selectors (p, div, blockquote, h1, h2, etc, etc.) will have margin:0, padding:0 and text indent:0. With the first option, for example if you don't define styles for the h1 tag, <h1> will have default values (that is, will have margins different from 0) but with the second option, <h1> wil have null margins, padding and indent. In short: with the second option, you'll set as default margin:0; padding:0 and text-indent:0 for all selectors and you'll be forced to establish values for them (if you want others values for those properties).

None of those options is wrong, to use one or the other will depend of what you want to do

Regards
Rubén

Last edited by RbnJrg; 11-01-2015 at 12:59 PM.
RbnJrg is offline   Reply With Quote
Advert
Old 11-01-2015, 01:45 PM   #3
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,459
Karma: 17222221
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Applying margin:0 to * will have the possibly undesired effect of removing the default margins for <blockquote>. If you are manually setting the blockquote margins, it doesn't matter.

As for the extra <div>, it's probably a (dirty) trick to allow having naked inline elements (<span>, <img>...) out of <p>s, since this is not valid in XHTML:

Code:
<body>
<p>Some text</p>
<span id="pg_2"/> <!-- span cannot a direct child to body -->
<p>Some text</p>
</body>
but this is OK:

Code:
<body>
<div>
<p>Some text</p>
<span id="pg_2"/>
<p>Some text</p>
</div>
</body>
Jellby is offline   Reply With Quote
Old 11-01-2015, 03:18 PM   #4
Arios
A curiosus lector!
Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.
 
Arios's Avatar
 
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
Hi Rubén,

Thanks for your fast reply!

I use these codes (* {...}) for a while so I know their purpose as well as their effects in (x)html files. My main question was rather: which one is better to use (¿Qué notacion es el mejor, en * {... o <body>?). Of course, if it matters for something (semantic or whatever)!

Thanks also Jellby for the clarification about the empty <div> and naked inline elements.

My rationale behind the use of these codes, is to set all things clean (general) and after that, I can set up all specific classes (<p>, <hr />, or <blockquote>, etc.) at my liking.

In truth I want to be more logical in creating my CSS and to do so, I tend to proceed from general to specific, putting emphasis on the semantic use of codes.

Last edited by Arios; 11-01-2015 at 04:22 PM.
Arios is offline   Reply With Quote
Old 11-01-2015, 09:50 PM   #5
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
I think it is clearer to place the defaults in the body. It makes it clear what they are for.

Dale
DaleDe is offline   Reply With Quote
Advert
Old 11-02-2015, 11:54 AM   #6
Arios
A curiosus lector!
Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.
 
Arios's Avatar
 
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
Thanks for your advice DaleDe,

I would have bet that "* {" is something directly related to CSS and <body> to (x)html files (something like <body dir="ltr", etc.>.

But, as noticed by Rubén both options work properly, which does not help to choose the best (semantic) one!
Arios is offline   Reply With Quote
Old 11-02-2015, 11:59 AM   #7
Turtle91
A Hairy 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: 2,683
Karma: 16000001
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2 & Air/Surface Pro/Kindle PW
I've heard many times to "keep structure in the html, styling in the css". So, if it is purely for default margin/padding/indent that sounds like styling and should go in the css.
Turtle91 is offline   Reply With Quote
Old 11-02-2015, 12:38 PM   #8
Arios
A curiosus lector!
Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.
 
Arios's Avatar
 
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
Very good point Turtle91!
Arios is offline   Reply With Quote
Old 11-02-2015, 12:43 PM   #9
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
Quote:
Originally Posted by Turtle91 View Post
I've heard many times to "keep structure in the html, styling in the css". So, if it is purely for default margin/padding/indent that sounds like styling and should go in the css.
Yes but body styling can also be placed in the CSS.

Dale
DaleDe is offline   Reply With Quote
Old 11-02-2015, 02:06 PM   #10
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,459
Karma: 17222221
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
"Semantic" means "meaningful". So the most semantic depends on what you mean.

Set the style for <body>? Then "body { ... }"

Set the default style for any tag? Then "* { ... }"

The first would have the side effect of also setting the style of anything that inherits from <body>. If your intent is taking advantage of this, then maybe you actually mean the second. If your intent is setting a "clean slate" for every possible tag, then you mean the second.
Jellby is offline   Reply With Quote
Old 11-03-2015, 11:15 AM   #11
Arios
A curiosus lector!
Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.Arios ought to be getting tired of karma fortunes by now.
 
Arios's Avatar
 
Posts: 463
Karma: 2015140
Join Date: Jun 2012
Device: Sony PRS-T1, Kobo Touch
Thanks Jellby for your advise,

Presently, I think I am on a "semantical trip" so to say! But it's probably more precise to talk about a relevant/effective/logical way to process. I'll study more attentively the CSS cascading mechanism.

PS There are 2 "second" in your reply. Do you mean the first ("Set the style for <body>") and "then you mean the second"?

Last edited by Arios; 11-03-2015 at 03:23 PM.
Arios 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
CSS <body> vs. <p> question Amalthia Conversion 7 01-21-2014 02:50 AM
force an addition to main body css ? cybmole Conversion 5 01-17-2014 03:35 AM
Adding body style to Extra CSS does nothing Barty Conversion 7 10-24-2013 12:06 AM
How to change the font-size in the body tag in css? naisren Conversion 2 10-01-2012 06:52 PM
css pseudo elements and adjacent combinators in extra css? ldolse Calibre 2 12-21-2010 06:09 PM


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


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