![]() |
#1 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
Epub CSS Stylesheet: body, html {...?
Originally, in my css stylesheet for my epubs, I had set of styles included in body:
body { ....; } In following some suggestions here: https://wiki.mobileread.com/wiki/CSS_HowTo#Essentials I also included html: body, html { ....; } What does including that html bit do? I'd assumed it applied those styles to the <html> section of the file as well as to the <body> section (which seemed odd since <body> is part of <html> (I think). I've just now pulled the html bit out of that statement since it appears to be causing margin issues with Calibre's Viewer: https://www.mobileread.com/forums/sh...d.php?t=348888 But, I'd still like to know if I should add it back. I just edit the css of the commercial books I buy to be easier for me to read on my Kobo Forma as a kepub. |
![]() |
![]() |
![]() |
#2 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
I notice that the mobileread Wiki page you link to specifies a margin in the pt unit. Kinda funny given the talk here.
I don't include html in an epub stylesheet. For webpages I put this on the html tag. It's something the browser probably does anyway but it just makes sure. Code:
html { box-sizing: border-box; } |
![]() |
![]() |
![]() |
#3 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 769
Karma: 1537886
Join Date: Sep 2013
Device: Kobo Forma
|
The problem is that trying to find something specific to html in a css stylesheet is darn near impossible. Basically, "html" is nearly universal for every search involving css. Unfortunately, it usually refers to the actual html and not the css.
|
![]() |
![]() |
![]() |
#4 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
On a website it's also common to include html in a standard block like this early on and then forget about it:
Code:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline;} aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block;} Last edited by bookman156; 09-02-2022 at 02:41 PM. |
![]() |
![]() |
![]() |
#5 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
Quote:
|
|
![]() |
![]() |
![]() |
#6 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,705
Karma: 103837201
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
ebooks happen to use HTML, images and CSS. But not in the same way. So forget about Websites.
|
![]() |
![]() |
![]() |
#7 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
Quote:
|
|
![]() |
![]() |
![]() |
#8 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,136
Karma: 144284184
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#9 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,136
Karma: 144284184
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,136
Karma: 144284184
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Because the person who put that in, did it in a way that you should not do. I would not style HTML and I would not use that body CSS. I've already posted body CSS that works very well.
|
![]() |
![]() |
![]() |
#11 | |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,705
Karma: 103837201
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Quote:
Ebook renderers are closer to how a browser prints on paper, but not the same as that either. You can set say A6 or some custom paper size on your printer, and on a decent OS & Browser (not iOS or Android) select Print Preview (without background image printing) after page setup to select the new paper size. A lot of web page stuff simply doesn't work on paper or print preview. No Animation, video or sound. Automatic headers and footers not in the web page. No sensible use of transparency. Many tables might break on your small paper size. Images might no be the same size relative to text as on the screen web page. It wouldn't be hard to make a browser with a "book" (i.e. codex) mode instead of infinite scroll, that behaved much like either Print Preview or an epub app were "paper size" is set by browser window size. I'd love it. I hate websites with a forever giant scroll. So 2300 years old! The Wiki is wrong. |
|
![]() |
![]() |
![]() |
#12 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,306
Karma: 78876004
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
|
![]() |
![]() |
![]() |
#13 | ||
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#14 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 368
Karma: 1000000
Join Date: Mar 2016
Device: none
|
That wiki reference does make the interesting point that a margin on the body for top and bottom only affects the first and last page, so use @page instead. Never thought about that before.
|
![]() |
![]() |
![]() |
#15 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,136
Karma: 144284184
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
That wiki has mistakes. This is just one of them. The body/html CSS is also wrong. I've never seen margins in the body style effect only the first and last page/screen of a chapter. <body> is like a <div> in that it surrounds what it is the body style is applied to. Last edited by JSWolf; 09-03-2022 at 10:03 AM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
HTML and CSS compilers to epub | Josh Aenon | ePub | 23 | 08-14-2019 12:12 AM |
pagestyle.css extra / integrated in stylesheet.css / or not at all? | chaot | Workshop | 14 | 02-24-2017 11:10 PM |
epub code snippets (html / css) | zelda_pinwheel | ePub | 196 | 10-09-2016 04:21 AM |
ePub margins : @page vs stylesheet.css | Agama | Calibre | 1 | 08-16-2010 04:37 PM |
EPub conversion stylesheet.css problem | nycaleksey | Calibre | 1 | 03-25-2010 11:42 PM |