Monday, April 7, 2008

Quick Tip: Margins

Margins in the Kindle are not very easy to format, but there are some tricks that will allow you to add some space between your paragraphs.

The first thing to realize is that the Kindle does not support the regular CSS margin styles. Any of those you use in your document will be completely ignored. The second thing to realize is that, even with the hacks presented here, there is currently no way to give an element a right or bottom margin. Only top and left margins are supported.

To apply a top margin to a paragraph or blockquote, you can add a height="" attribute to the tag. This attribute supports pixels (as a number only: height="30"), percentages (height="10%"), and em-sizes (height="3em"). Here is an example using pixels:

Pixel margins

To apply a left margin to text, you will need to place your text within nested blockquote tags, like this:

<p class="noind">Poetry level 1</p>
<blockquote>Poetry level 2</blockquote>
<blockquote><blockquote>Poetry level 3</blockquote></blockquote>
<blockquote><blockquote><blockquote>Poetry level 4</blockquote></blockquote></blockquote>
<blockquote><blockquote><blockquote><blockquote>Poetry level 5</blockquote></blockquote></blockquote></blockquote>

which looks like this:


Notice that there is a limit to the amount of indentation allowed, apparently about 4 levels. Also, notice that I have used a class="noind" in the first paragraph. This calls a p.noind{text-indent:0;} style that removes the default first-line indent applied to paragraphs in the Kindle.

If you have any questions about this or other Kindle formatting issues, or need help with your book, please drop me a line!



Links to this post: