![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
uninvited "user agent stylesheet"
Hi
One friend of mine showed me an illustrated book in odt format so that I could test a converter. I was surprised by the display of some images on the EPUB: it seemed like there was an unexpected added margin around them. I used the Calibre inspector to check what happened with the CSS. I found that a "user agent stylesheet" had crept in and wrapped a 8px margin around the image. It was unherited from the body value of this uninvited stylesheet. Mr "User agent" had other ideas too about h2 and h3 like font-size, webkit-margin-(before, after, start, end), font-weight... I did not have set margin for the body, but nevertheless I found this behaviour very surprising because these foreign values do not appear anywhere in the code. Had not the Inspector been around, I would have been totally puzzled. How to prevent these "user agent stylesheets" to come in again unexpected and unrequested? |
![]() |
![]() |
![]() |
#2 |
Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
|
A UA stylesheet is provided by each book reading platform, and provides its default styles. You can't prevent them from being there; they just are. All you can do is override anything that you consider to be important.
A word of caution, though.... Some readers misbehave badly when you try to set the page or body padding/margins to non-default values. So when you zero the margin, do so on the img tag, not the body tag. ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Quote:
Taking into account your advice not to set the body margin to zero to avoid some readers misbehaviour, I thought I could be possible to use a negative margin in the img tag so as to counter the unwanted body margin. Using frame styles, it can be a quick process. It could work only on the margin-top and margin-left values though but it's valid CSS. Last edited by roger64; 12-26-2014 at 08:12 PM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Facebook asserts trademark on word "book" in new user agreement | no.guru | Lounge | 4 | 03-29-2012 10:38 PM |
Meet "Arielle" -- the Sex Doll Literary Agent! | BenG | General Discussions | 4 | 12-20-2010 01:02 PM |
Unutterably Silly Motiv für unsere social group "deutschsprachige User" | ravenne | Lounge | 75 | 04-13-2009 02:48 PM |