06-23-2013, 08:37 AM | #1 |
Addict
Posts: 340
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch, Pocketbook Touch HD
|
Display block ... why? (Question about CSS and Calibre)
Hello
I hope someone can explain this to me. I created an xhtml File, together with a css file. I used normal "p" tags. After that, I converted it into an epub, with Calibre. Then I looked at the finished epub file and notices, that it changed some of my css. What surprised me most is: On all p-tags in my css, Calibre added "display: block". Same goes for the headings and div tags. Why? Is there a good explaination, why I should use display:block on epub files? Is this related to Widows and Orphans (I hope you know what I mean) or is there another good reason why I should use it? Thanks in advance for your help. |
06-23-2013, 09:27 AM | #2 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
https://www.mobileread.com/forums/forumdisplay.php?f=203 http://web.sigil.googlecode.com/git/...with_epub.html Regarding the "display: block" property added to your <p> tags that doen't matter; maybe you don't know it but <p> tags, by default, by omission, has the property "display: block". To write it (or not to write it) is the same for <p> tags. Regards Rubén |
|
06-23-2013, 10:17 AM | #3 |
Color me gone
Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
As I understand it display block forces it to occupy the width of the page and is normally displayed with blank lines before and after.
As was pointed out, this is unnecessary and if not removed, would keep you from making any special changes in the text for quotes or other special formatting. This sort of thing is why it is best to simply bring your html into Sigil and edit it there. Sigil does not change your text unless you ask it to, or unless you activate HTML Tidy, which is generally not recommended. Sigil will allow you put any change you want and facilitates the process by using "clips" which allow you to insert commonly used tags, words, etc of your choice. If you have an xhtml file, you can open it in Sigil, then add additional file for your stylesheet. You need to do one more step, rightclick on the xhmtl file(s) and choose to link them to the stylesheet. This step is necessary in case you want to use more than one stylesheet for the various files. (one for poetry sections, another for plain text, or another for dialog sections. Unless your work is quite short, you probably should keep sections under about 250k or so. This allows your epub to work in older readers and speeds rendering in new ones. Press control and enter at the end of each chapter and that will generally create reasonable size sections that work well. |
06-23-2013, 10:41 AM | #4 |
Fanatic
Posts: 580
Karma: 810184
Join Date: Sep 2010
Location: Norway
Device: prs-t1, tablet, Nook Simple, assorted kindles, iPad
|
Lately I've been wondering why I should use <p> instead of <div>?
Sometimes it's pretty annoying not to be able to nest block-type elements within <p>-tags. |
06-23-2013, 11:04 AM | #5 | |
Well trained by Cats
Posts: 29,801
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
<div has none, no defaults IMHO dive is a simple (box) container that can be customized As with package shipping, use the best container designed for the article being shipped/displayed. There is a whole section in CSS2 devoted to 'Block' (9: Visual formatting Model) [most which goes over my head ], but as I get it; controls how all the boxes are stacked together within the Cascade |
|
06-23-2013, 11:31 AM | #6 |
Fanatic
Posts: 580
Karma: 810184
Join Date: Sep 2010
Location: Norway
Device: prs-t1, tablet, Nook Simple, assorted kindles, iPad
|
<p> has a default top and bottom margin, <div> does not.
Both are block-display elements, but <p> only permits embedding inline-display elements. You can partially work around this by redefining the display property from inline to block for e.g. <span> elements, but it feels a bit icky... The only downside I can see is by replacing <p> with <div> is that paragraphs are not separated by a blank space in readers that do not support CSS. |
06-23-2013, 02:09 PM | #7 | |
Addict
Posts: 340
Karma: 43106
Join Date: Apr 2009
Location: Germany
Device: BeBook One, Pocketbook Touch, Pocketbook Touch HD
|
Thanks so far for all your replies.
Quote:
The thing why I mentioned Calibre is: of course, I unpacked some of the Calibre epubs and looked at the different files, to learn some things. That's how I discovered the display: block stuff. I wasn't sure, if I can get an advantage from it or not - but I guess, I can keep my css like it is right now (without the display: block) Thanks again. |
|
06-23-2013, 09:26 PM | #8 | |
Resident Curmudgeon
Posts: 73,975
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Display simple math expressions with CSS | phossler | Sigil | 16 | 06-16-2013 08:30 PM |
css question | ralphiedee | Sigil | 74 | 12-23-2012 06:29 AM |
CSS Question | jackibar | Sigil | 24 | 03-01-2012 09:12 AM |
Does mobi support display: inline-block; | DeniseL | Kindle Formats | 2 | 09-30-2011 07:33 PM |
CSS Question | AppleTard | Calibre | 1 | 06-12-2011 12:07 AM |