1. Computing
Send to a Friend via Email

Discuss in my forum

HTML Elements for Kindle Ebooks

What Elements You Can Use in Your Ebooks

By

One of the nice things about writing ebooks is that if you already know HTML, then you know a lot of the tags you can use for writing ebooks for Kindle (mobi) or EPub. There are many HTML elements that you can use, and only a few that absolutely don’t work.

Unfortunately, it’s not possible to say that the Kindle supports any one specific version of HTML (such as HTML 3.2 or HTML5) because there are some elements that are not supported that are part of the HTML specification. This means that even if you write your book in HTML, you will need to know which tags not to use as well as a few custom tags to help with your formatting.

Basic HTML Elements for Your Kindle Book

When you’re building your Kindle book, you use almost all the same HTML elements you use on a web page, including:

You use these elements exactly the same way you would in a web page document. The TITLE should be the title of your book and the BODY contains all the text of your book. So your ebook starts out looking like this:

<html>
<head>
<title>The title of your book</title>
</head>
<body>
The book contents </body>
</html>

Basic Formatting

Kindle books use standard HTML elements to define paragraphs, line breaks, headlines, and even block quotations. You also can use standard HTML elements for italics, bold, underline and strikethrough. The only thing you should be careful about is closing your elements, even the <p> </p> element and the <br /> element. Use these elements to format your text:

You can also adjust the size of your fonts with the BIG and SMALL elements. And if you need superscript or subscript text you use the SUP and SUB elements. And you can also use the CODE, KBD, SAMP, and TT elements to make your text mono-spaced. Plus, you can add horizontal lines (HR) and images (IMG).

But when you build your Kindle HTML file, you also need to include the A element with a name attribute. You should name all your chapters as well as the start of the book and the table of contents. Use the following names for your structure:

  • <a name="start" /> — This is the start of the book. It’s where the book will open the first time someone reads it. You can use it to skip over title and dedication pages and get your readers right in the meat of the book.
  • <a name="TOC" /> — Place this at the top of your table of contents.
  • <a name="chap1" /> — This should be placed at the front of Chapter 1, with similar ones at the beginning of other chapters.

Always put the named anchors before any formatting tags. So <a name="chap1" /><h2>… is correct but <h2><a name="chap1" />… is not.

You can then use the A element to link to named anchors in your book or to HTML documents already on the web, just like you would in an HTML web page.

Finally, there is one more element you need to know about, only this one is not HTML, it’s Kindle specific: <mbp:pagebreak/>. Remember that HTML is not a paged format, but ebooks are. In most cases, it won’t matter as the Kindle devices will add page breaks where it’s appropriate. But there are certain places you want to make sure that the book starts on a new page:

  • Dedication
  • Publication data
  • Table of contents
  • Chapters
  • Index and Appendices

There are two other Kindle specific elements you can use, but they are not as commonly used:

  • <mbp:nu>
    This indicates that the enclosed text should not be underlined. It overrides any other font properties applied.
  • <mbp:section>
    This defines a book section.

Putting all this together, your HTML file will look like this:

<html>
<head>
<title>The title of your book</title>
</head>
<body>
<p><img src="cover.jpg"/></p>
<a name="start" /><h1>Your Book Title</h1>
<h2>Sub-Title</h2>
<h3>By Your Name</h3>
<mbp:pagebreak/>
<p>Copyright © Your Name The Year. All rights reserved.</p>
<p>Published in Your Country</p>
<p>First publication date <em>Month, Year</em></p>
<mbp:pagebreak/>
<p>Dedication</p>
<mbp:pagebreak/>
<a name="TOC" /><h2>Table of Contents</h2>
<a href="#chap1"><h3>Chapter 1</h3></a>
<a href="#chap2"><h3>Chapter 2</h3></a>
<a href="#chap3"><h3>Chapter 3</h3></a>
<mbp:pagebreak/>
<a name="chap1" /><h2>Chapter 1</h2>
<p>...</p>
<mbp:pagebreak/>
<a name="chap2" /><h2>Chapter 2</h2>
<p>...</p>
</body>
</html>

Elements that Do Not Work on the Kindle or That Don’t Work Well

The PRE element is not supported by Kindle. If you need content to be written in monospace font, you should use one of the monospace elements and possibly BLOCKQUOTE. But you’ll have to set up the formatting yourself.

You should also avoid elements like FRAME and IFRAME that work with the page layout. Think of Kindle books as very simple web pages, and the more complex you try to make them, the more problems you will have.

Kindle books display the text as it’s written. You can do some alignment with the align attribute, but the CSS float property doesn’t work. This can be frustrating if you’re trying to lay out your ebook pages like you might a web page. The best thing to focus on for your ebooks is to keep the formatting and layout simple.

There are also a few things that are not supported in the oldest Kindles (Kindle 1) but do fine in Kindle 2 and newer. Like tables and borders. Kindle 1 users are still out there reading a lot of books, so it’s a good idea to simply avoid these features so that your book looks good for them.

Always Test Your Book

If you have a Kindle device, you can email your HTML file to the device and view it that way. This will show you how your book will display and give you an idea of what is working and what isn’t.

©2014 About.com. All rights reserved.