Kindle Formatting: The Complete Guide to Formatting Books for the Amazon Kindle

Home > Other > Kindle Formatting: The Complete Guide to Formatting Books for the Amazon Kindle > Page 5
Kindle Formatting: The Complete Guide to Formatting Books for the Amazon Kindle Page 5

by Joshua Tallent


  The Kindle displays superscripted and subscripted text using the and tags. The text inside those tags is not only shifted up or down on the line, it is also reduced in size. The tag is most commonly used to format footnote numbers, like this:

  Jules Verne makes his story more believable by setting the events in his own time.1

  The tag around this footnote will be explained on page 113.

  The and tags can both be used to create consistently-styled fractions. The line height of the line with the fraction on it will be expanded a bit, but the overall effect looks pretty good despite that.

  The story was 1/2 as long as the author intended.

  Note that the Kindle does not allow tweaking of the line-height CSS property or the vertical-align property, so there is no way to adjust the placement of the superscripted or subscripted text. It also does not allow you to change the size of the characters in the or tags.

  Strikethrough

  There are two HTML tags that allow you to strike out some text (place a line through it): the and tags. These both look exactly the same on the Kindle.

 

strikethrough text



 

this is strikethrough text



  This image also shows a small bug in the implementation of the formatting on the Kindle screen. In the first example, because the text of the entire paragraph is formatted in a strikethrough tag and because that text is the first text on the page, the first word is not given the strikethrough style. If there were a single character before the tag the bug would not be present.

  On the Kindle 2 the placement of the strikethrough line has changed. It now shows up closer to the middle of the word than it does on the Kindle 1. Notice that the same formatting bug is present in the Kindle 2.

  You can also apply a strikethrough style to any tag in your style sheet using the text-decoration: line-through; property.

  Span Tags

  The tag is a multi-purpose tag that does not apply any style of its own to the text. Instead, it is used to apply styles from a style sheet or inline styles to the text it surrounds. As we discussed at the beginning of Chapter 4, tags are over-used by programs like Word and Acrobat, being strewn throughout a file to assign styles that would be better applied elsewhere.

  There are not many cases where a tag will become necessary in your book. Most of the styles you will be applying have tags of their own. However, it is available if you find the need to use it.

  Code and Other Mono-spaced Text

  Coinciding with the release of the Kindle 2, the Kindle 1 firmware was updated to support the use of a mono-spaced font. This is very useful for inserting computer code into a book, just like I do throughout this one. To apply this style, you will need to wrap the text in one of the following tags: , , , or .

  The Kindle does not support the use of the CSS style font-family: monospace; for applying a mono-spaced font. That means all of your mono-spaced text must be in one of the above tags.

  Also, the
 tag does not work on the Kindle.

  Paragraphs

  The Kindle supports six main types of paragraph formatting:

  Normal: The Kindle applies a standardized first-line indent and full justification to every paragraph.

  No-indent: This will override the first-line indent and make that line flush left.

  Left-aligned: This will override the default full justification and make the right edge of the paragraphs jagged.

  Right-aligned: Text will be aligned on the right of the screen and the left edge will be jagged.

  Centered: Text will be centered on the screen.

  Hanging: You can use hanging indents to make poetry, bibliographies, and even lists.

  Let’s discuss these formatting options in detail.

  Default Paragraph Formatting

  When you place a

tag in your HTML file the Kindle will apply some default formatting to it. This was most likely done in an effort to make every book seem more consistent on the screen, but it has led to some consternation among those of us who format Kindle books because it means you have to override the formatting explicitly in your file if you don’t want it to be applied. Thankfully, the ability to override some of the default formatting does exist.

  The default formatting that is applied to regular paragraphs is a consistent line height, a first-line indent that stays at 0.25 inches (about 0.6 cm) regardless of the font size chosen by the user, and justified paragraph formatting (which means that the text is aligned both on the left and right of the screen). Of those three styles, the line height is the only one that cannot be overridden in the code (though, on the Kindle 2, users have the ability to specify the line height they want using the Alt + Shift + Number shortcuts). We will discuss the other two styles in the sections to follow.

  You can apply a larger first-line indent to your paragraphs if you think that the 0.25 inch indent is not enough. To do that, use the width attribute in your paragraph tag like this:

 

There were two or three things that I wanted to know. I do not care about a mystery....



  The value in the width attribute can be in:

  pixels (width="40"),

  points (width="40pt"),

  percent (width="10%"),

  or em-units (width="2em").

  A Note about Measurements

  The Kindle accepts four common measurements in its width and height attributes and in certain CSS attributes. These four measurements are pixels, points, percent, and em-units. The pixel and point measurements are treated exactly the same on the screen, so I usually just use the pixels. When you use pixels in the width and height attributes, you should not include “px” or “pixels” in the value—just give it a number with no units (e.g., width="30").

  Percent will apply a percentage of the screen measurement to the attribute. I have seen this unit of measurement be a little bit unpredictable, so it might be best to leave it alone.

  Em-units are generally defined as the full height of the font being used. In web browsers an em is a variable unit that expands and contracts with the font size, but on the Kindle the em has a static size. The real problem, however, is that the measurement is different on the Kindle 1 and the Kindle 2. On the Kindle 1, an em is 1/4 of an inch, while on Kindle 2 it is 1/8 of an inch.

  As you see on the next page, this difference in size can make a big difference in the formatting. Figure 5.1 shows how the Kindle 1 displays ems and Figure 5.2 shows how Kindle 2 does.

  Figure 5.1: Em's on Kindle 1.

  Figure 5.2: Em's on Kindle 2.

  Pixels are a stable measurement on both devices, so I suggest you stick with them unless or until Amazon fixes these differences.

  No-indent Paragraphs

  To override the default first-line indent applied by the Kindle, you can choose to use a CSS rule or an in-line width command. I suggest using the CSS rule since it is easier to adjust later if the need arises. Let’s say you want to apply a no-indent rule to every paragraph that follows a heading. You can assign a class name to the paragraphs you want to change and give that class the “text-indent:0;” style in the

  ..........

 

Man About Town



 

There were two or three things that I wanted to know....



  If you wanted to make that change to the HTML file easily, you could use a regular expression like this one:

  Find: n



  Replace: n



  To apply the no-indent style to one paragraph without using CSS, assign the paragraph a width="0" attribute like this:

 

There were two or three things that I wanted to know....



&nbs
p; Notice how the difference in em-units display affects the book indentation in these photos of the Kindle 1 (left) and Kindle 2 (right). You can also easily see the difference in default line heights.

  What if you wanted to apply the no-indent style to all of the paragraphs in your book? You could do it by taking out the class name from the style example given above, like this:

 

  However, that may have unintended consequences on your book layout. You could also assign the

class to all the regular

tags in your book. That would be a little bit more targeted. If you do assign the no-indent rule across the book, you should take a look at the section on margins on page 68 to learn how to give your paragraphs a top margin so that the text does not run together too much.

  Left-Aligned Paragraphs

  The Kindle assigns a default full justification to all of the paragraphs in the book. This means that text will be aligned flush with both the right and left margins of the screen. Sometimes this formatting makes the text on a line spread out with lots of space between words, especially when a long word or a hyperlink is forced to wrap to the next line. Of course, this effect will vary depending on what font size the user is reading the book in. On the Kindle 1 this justification can also be turned off by the user for all books in a special, hidden command (Alt + J in the Font Size menu). This feature is not available on the Kindle 2.

  If you want to override this formatting in your book, you can assign the “text-align: left;” style as desired. For example:

 

  ..........

 

Chapter 1



 

There were two or three things that I wanted to know. I do not care about a mystery. So I began to inquire.



  Of course, you could also combine that with the no-indent style discussed above to remove the default first-line indent.

  To assign the left-align style to an individual paragraph you can add the following attribute to the paragraph tag:

.

  Example of left-aligned text.

  Right-Aligned Paragraphs

  Sometimes you will want a paragraph to be aligned on the right side of the screen. I have found that this works well for signature lines at the end of a Foreword or Preface. To do this, you will assign the “text-align: right;” rule to the paragraphs. For example:

 

  ..........

 

Very Sincerely Yours,



 

O. Henry



 

New York, 1906



  It is important to remember that the first-line indent style will still be applied to these paragraphs. That extra quarter of an inch can make a big difference in longer paragraphs, so you might want to apply the no-indent style explained above to remove the first-line indent.

  To assign the right-align style to an individual paragraph you can add the following attribute to the paragraph tag:

.

  Centered Paragraphs

  To center a paragraph on the screen, use the “text-align: center;” CSS rule. For example:

 

  ..........

 

Man About Town



 

by



 

O. Henry



  You can also assign the center-align style to an individual paragraph by adding the following attribute to the paragraph tag:

.

  One more way to center content is to use the

  Notice that the paragraphs in this example should still have the first-line indent removed (in this case, with the “noind” class we discussed above). Overall, I find the r />   Notice that the
tag has the closing slash we talked about on page 28. While it is not required, it is the preferred practice in XHTML.

  Division Tags

 

tags are normally used in HTML to divide the contents of the document into sections. These tags are very useful for doing page layout on websites, but on the Kindle they effectively become just another form of

tag. You can apply the same styles and formatting described above to the

tag.

  Block Quotes

  One commonly used text format is the block quote. Offical writing style guides (Turabian, MLA, APA, Chicago, etc.) differ slightly on when block quotes should be used, but the general rule is that they should be used whenever the text being quoted is longer than just a snippet quoted in a sentence.

  In regular HTML, multiple paragraphs can be included in the same
tag. On the Kindle, however, if you have

tags inside a

the
will be completely ignored and the regular paragraph style will be applied. To make block quotes on the Kindle, then, you must remove the paragraph tags and use
tags in their place. For example:

 

The man from the West unfolded the little piece of paper handed him. His hand was steady when he began to read, but it trembled a little by the time he had finished. The note was rather short.



 
Bob: I was at the appointed place on time. When you struck the match to light your cigar I saw it was the face of the man wanted in Chicago. Somehow I couldn't do it myself, so I went around and got a plain clothes man to do the job.

‹ Prev