Hot answers tagged

12

In general, formatting with HTML (though regarded as outdated by many, including W3C) tends to work more reliably than formatting with CSS. Support to CSS varies and can be disabled (though this is rare and mainly applies to web browsers). However, HTML formatting is very limited. You can use <i> for italic, <sup> for superscript, and a little ...


9

You will probably run into problems doing it that way, particularly on iBooks. The most reliable method I've found for centering is: <div class="centered_image"> <img src="image.jpg" alt="Alternate text" /> </div> With css like this: div.centered_image { width: 60%; margin: 1em 20%; } div.centered_image img { width: 100%; } On a ...


9

You can definitely embed fonts, yes. There are a few issues to watch out for when doing so, however: You may not have a license to use the font in ebooks. The font needs to be licensed in such a way as to not just allow use, but also distribution. There are a number of open source fonts available that do permit redistribution--make sure you read the license,...


8

Quite a few rendering engines are actually taking @page into account. Others like iBooks or Kindle are ignoring it and overriding the margins' values set for body with default values. I can confirm @page works well in Adobe Digital Editions -- and some but not all apps + devices using Adobe's RMSDK. To sum things up, you can use it to set a margin for ...


8

Your best bet is to start with a solid epub file and run that through either KindleGen or Kindle Previewer. Other tools such as Sigil and Calibre are convenient, but often cause problems down the road by inserting their own bits of code. If you want to be certain that you know what is causing your problems, it's always best to do it yourself. The single ...


7

There are a few things going on here. The spacing issue is likely being caused by the presence of block elements inside list elements—the headers are probably getting bumped onto their own line, apart from the start of the list item. If you're starting with the toc.xhtml of an epub file, you'll need to lose any elements inside the Table of Contents ...


7

Paul Salvette wrote an ebook formatting guide which I recommend. He wrote boilerplate css which you can view/download here: http://bbebooksthailand.com/bb-CSS-boilerplate.html His company has produced some epub3 files which you can download for free. http://bbebooksthailand.com/samples.html (You can inspect them by changing the .epub file extension to .zip ...


6

There are two possibilities here, and without seeing more of the book's code, it's not really possible to tell. The first is that this is extra functionality offered by the reading system rather than something built into the epub file itself. As noted by Liz Castro in the spec, this is similar to Apple's example of supporting symantically marked footnotes,...


5

Personally, I never minify code in ebooks. A big part of the reason for that is that unlike many here, I don't use Sigil or Calibre to edit my epub files—I use either Notepad++ or Geany depending on the OS I'm working in. Because I'm always working with the code, it does nothing but make my life harder if I've minified the whole thing and the client ...


5

I think that every device has its own behaviour, so I don't know if there is some setting that can be used as a general solution. In example, I have a Kobo ereader, and it is capable to do what you ask; if there is a custom font inside the ebook, and it is used only for titles or some paragraphs (i.e. to format code in computer science books), for the rest ...


4

For better compatibility, especially with older devices, you should stick with more basic HTML primitives. Those devices do not implement advanced browser functionality. The rendering engines in the ebook devices are lagging behind even more than desktop browsers as they need to be more stable (because upgrading is mostly out of the question). So recon you ...


4

You can use the following CSS rules to style respectively even or odd table rows (See the Example on W3schools): tr:nth-child(even) { background-color: #f2f2f2 } tr:nth-child(odd) { background-color: #f2f2f2 }


3

The preferred solution (and the one I use) is to create default css outside of the media query breakpoints, and then this css will apply to e-ink devices (which don't support media queries -- even the amzn-mobi one, to my knowledge) You should check the PDF of "Amazon Kindle Publishing Guidelines" on their website. Current version is 2015.4 I think your ...


3

You can certainly specify custom fonts for Kindle books; that's what section 3.1.9 is all about. Section 3.1.1 is only talking about the things that it mentions: Forced alignment (because Amazon would rather force the ancient print relic of justified text throughout) Body text size Bold and italics on body text White or black color for body text White or ...


3

You can try to suppress both those tags using CSS in an included .css file (or inserting in the HTML code between <style> and </style>): span.titlemark, span.titlemark + br { display: none; } But you would have to test that on all devices to see if their renderers correctly handle it.¹ If you don't want to go into the effort of testing ...


3

The epub 3 toc.xhtml was created specifically to do away with the need to have separate logical and visual ToCs. Unfortunately, it's not quite there. As long as you're only interested in adding some styles to the text, though, you should be fine. Where you start to run into problems is if you want to have lots of other stuff going on in your ToC, like a ...


3

If you have an html editor which supports wild card or RegEx search and replace like Adobe Dreamweaver you could delete these out of the source code very quickly. See image below- Also you can go to RegEx tester sites like these to form the most effective search expression for your needs. http://regex101.com/


3

There is now a setting in MoonReader to disable publisher's CSS. But even when it's not checked, not all CSS is supported. I've tested multiple Android Epub readers with a bilingual epub I made, where the two languages are distinguished by the background colour and the font style (the second language is in italics). Only the Gitgen Epub reader displays the ...


3

According to this blog article, you should use the display: inline-block property on a div selector that encloses your header and paragraph. Here is an excerpt from the said article: If you set the display property for a div to be inline-block, iBooks will display the contents of the entire div together on a single page, skipping to a new page if ...


3

I would use h4 {page-break-after: avoid;} p { widows: 2; orphans: 2; } I think this works for Kindles as well as epubs. This is just example code. My guess is that this is structured content you would want to use a special class for the paragraphs below the h4. I would not be surprised if the Kindle e-ink devices do not support this css property ...


3

I eventually found out that I can use style="font-size:90%;" which is not exactly what I wanted but is sufficients for my needs.


2

In addition to the resources Tom listed, Joshua Tallent's book Kindle Formatting will give you tips for working around formatting problems. It's an old book and doesn't cover Kindle Format 8, but if you run into issues, it might give you ideas to try. Fortunately, KF8 has fewer limitations than MOBI 7, the older Kindle format, but the book will help if you ...


2

This site provides pretty good case-by-case metrics for CSS support by device / reader http://epubtest.org/results/ You are absolutely correct about your assumption that the Moon+ reader is overlaying it's own generic CSS over the publisher provided CSS. This has been a battleground in the ebook world for a while now but we are starting to get more support ...


2

EPUB 2 specifies content as supported property in the list of CSS properties. However, it is based on CSS 2.1, where the content property is allowed only for :before and :after pseudoelements. As the linked EPUB 3 spec shows (by linking to CSS 2.1), the same restriction applies in EPUB 3. Thus, the code in the question won’t work, to the extent that it ...


2

As a best practice, avoid font-size, margin or other css instructions when creating an ebook. An ebook is supposed to be just text and be made available to the device "as is". This allows the user to change the font family and size as he/she wishes. I know, being familiar with PDF or the layout with a webpage in the beginning the tendency is to translate ...


2

Assuming you're familiar with HTML and CSS, and given that your content has a lot of commonality to it, it would be fairly straightforward to set up a template file with all the parts you need for an ebook. You could, for example, have a template made of files like this: cover.xhtml title.xhtml toc.xhtml prologue.xhtml intro.xhtml chapter.xhtml appendix....


2

Paste the following in the 'User stylesheet', click ok. Then go to 'Theming' and save the style with whatever name you like. The e-book will display nicely in any screen mode and there are a couple of neat little extras you won't see with other user themes. As with all CSS it can be further altered and tweaked to suit. html { background: #e6e9e9; ...


2

There is no need to give every paragraph a class, the definition at 1. will apply to every paragraph, with or without a tag, and only on paragraphs that are directly below a footnote the settings will be overruled by those of the CSS of 2. You might not even need to have the CSS at 1., but for the defaults of the ePub reader.


2

It can be accomplished with the page-break-after (link) or page-break-before (link) CSS properties. Pretty obviously, these create a page break after or before the element that they are applied on. Here are a couple of examples of their use: page-break-after CSS style .newpage { page-break-after:always; } HTML code <p class="newpage">This ...


2

If you set properties for <body>, it will affect even elements like headers (<h1>...<h6>), lists (<ul>, <li>), and everything else, not just regular paragraphs (<p>). This could be what you want to achieve, but in the most common scenarios, I think that it is better to style every element on its own. In example, text ...


Only top voted, non community-wiki answers of a minimum length are eligible