How To Format Your Ebook For Kindle

Look, it is not difficult, possibly time-consuming, yes, but if you stick with it you can do it. The result will be a professionally formatted book and that will put you ahead of the game since most ebooks I read have quite a few formatting errors. And yes, that does include a lot from companies big enough to know better than to put out an inferior product. The process might take several hours, but haven’t you spent several months/years writing the book? A little time now will be time well spent.

Here is how to do it in easy steps (note, I am talking about a novel here – if you have a book with tables, pictures, etc. then you will need to do some more research). Before we start get used to making regular backups as you go along. I don’t mean regular saving I mean copies so you can always go back to a previous version.

I am going to be asking you to remove text from inside the html tags. For instance later I will say remove the text inside the italic tags: <i style=”mso-bidi-font-style:normal”>Text in italic</i> leaving: <i>Text in italic</i>. You can do this by hand or using the find and replace function in Notepad to make changes throughout the document. I find TextCrawler (freeware) a useful piece of software for finding and replacing text in files.

1. Save your document as a webpage. That is webpage filtered in Word. Now I don’t know what Microsoft mean by “filtered” because filtered the result certainly isn’t as you will see in the next step.

2. Open your document using Notepad or similar and marvel that the mess you see before you could ever become a properly formatted book. Inside it will look something like this:

<p class=MsoNormal style=’margin-right:432.0pt;text-autospace:none’><span
style=’font-family:Consolas’>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span></p>

3. Near the top of the document you will see some style tags. Starting with:

<style>

and ending with:

</style>

Remove everything from between the tags and put the following in place so altogether it now looks like this:

<style>
p { text-indent:1.2em;margin-top:0px;margin-bottom:0px;}
p.noindent { text-indent:0;}
p.centstar {text-align:center;margin-top:20px;margin-bottom:20px;}
p.cent { text-align:center;text-indent:0; }
h1 { text-align:center; margin-top:120px; margin-bottom:60px; }
h2 { text-align:left; margin-top:60px;}
h2.cover { text-align:center; margin-top:60px;}
</style>

4. Find your chapter headings and strip out all the html around them.

5. Surround your chapter headings with so called H1 tags, like this:

<h1>Chapter 1</h1>

5. Before each chapter heading put the Kindle page break html:

<mbp:pagebreak />

Don’t worry about how breaks appear in the text because html does not take any notice of whitespace or breaks. Only code between the tags can effect how the text can display.

7. On the first line of each chapter (right before the first letter) place the following html: <p class=”noindent”>

8. Find the breaks between scenes within each chapter (hopefully you will already have marked these with something like a * when you were writing). Surround the star with the following html:

<p class=”centstar”>*</p>

9. The paragraph following a break should, like the beginning of a chapter, have no indent so put the following tag:

<p class=”noindent”>

10. Take a break and have a cup of coffee! And do another backup.

11. Now you are going to start stripping out all the superfluous html in the document. Each paragraph in your document should start with <p> and end with </p> (except, as we have seen, the paragraph at the start of each chapter and after a scene break which should start with <p class=”noindent”>).

12. Find any italic tags: <i style=”mso-bidi-font-style:normal”>Text in italic.</i> and remove the text in the start tag so the tag looks like this:

<i>Text in italic.</i>

The text inside the tags (what is in the < >) may not look like mine, It doesn’t matter, get rid of it.

13. Do the same for bold tags.

14. Now work your way through the file finding and replacing any other tags so that each paragraph starts with <p> and ends with </p> and that in between is nothing else except italic tags <i> or bold tags <b>. You may well see lots of span tags: <span>. Remove them and anything in them.  Between the opening <body> tag and the closing </body> tag (right at the foot of the document) there should be nothing else but the P tags starting <p> and ending </p> and italic and bold tags. The only text inside the tags should be the class=”noindent” at the start of chapters and scene breaks and the class=”centstar” at the scene breaks. Just to repeat – the only tags should be <p>, <i> (or <em>), <b> (or <strong). There shouldn’t be a need for any other tags and you can remove them all. The only exception will be if you have some clever layout you need to use like trying to simulate a newpaper or document etc. or some other special display. In those case you will probably be able to work out the formatting yourself (or Google it) but you must make sure it displays correctly on the Kindle.

15. Go to the top of the document and find the opening <body> tag. Place the following afterwards:

<h1>Your Title</h1>
<h2 class=”cover”>Your Name</h2>
<mbp:pagebreak />
<p class=”cent”>Your Title</p>
<p class=”cent”>Your Name</p>
<p class=”cent”>Copyright &copy; 2011 by Your Name</p>
<br/>
<p class=”cent”>This is a work of fiction, etc., etc.<br/>
No part of this book my be stored, etc., etc.
</p><br>
<p class=”cent”>
This ebook is licensed for your personal enjoyment. This ebook may not be sold etc. etc.
</p>

(change the text above to suit. You can also put any other information here, like acknowledgements, although I prefer to put those at the end of the book.)

16. After this should come your first chapter which should already have the pagebreak tag before it (unless you want a table of contents in which case follow the next point).

17. If you want a table of contents then insert the following after the last line of the code detailed in point 15.

<mbp:pagebreak />
<a id=”toc” />
<h3 class=”cover” style=”margin-top:0;margin-bottom:20;”>Contents</h3>
<p class=”cent”><a href=”#start”>Chapter 1</a></p>
<p class=”cent”><a href=”#chp2″>Chapter 2</a></p>
<p class=”cent”><a href=”#chp3″>Chapter 3</a></p>
<p class=”cent”><a href=”#chp4″>Chapter 4</a></p>
<p class=”cent”><a href=”#chp5″>Chapter 5</a></p>

(add additional chapter links as required)

Now you need to add the anchors next to the chapter headings so go to chapter one and add the following:
just before your <h1> tag;

<a id=”start” />

Note the first chapter or prologue must have the link id “start” because this is what the Kindle looks for when a user wants to navigate to the beginning of  the book.

For the chapters following add this code before each <h1> tag BUT CHANGE THE NUMBER TO MATCH. In this case this is where the link above which says <a href=”#chp2″>Chapter 2</a> will go to:

<a id=”chp2″ />

Do the same until you reach the last chapter.

If you don’t want a table of contents then skip this point (17) entirely.

18. Now you can preview your work by right clicking on the file and choosing “open with” your web browser. There won’t be any page breaks – the document will run in one huge page – but everything else should look OK.

19. Now get it into PRC format. You will need Mobipocket Creator for this. Follow the instructions to create your ebook and then drag and drop it onto your Kindle (or preview using Kindle for PC or even better the Amazon Kindle Previewer. Click here and scroll down the page to find it).

20. Read through the whole book looking for formatting errors. Most of these will be because you have missed extraneous html inside tags that does not need to be there. When you find them go into the html file and correct. Repeat the ebook creation process numerous times until you are happy with the result.

21. You should now have a perfectly formatted book.

22. Upload the PRC file to Amazon KDP.

23. Wait for the plaudits to come in!

Please note: As I have said above, this information concerns formatting for a novel with no fancy text or layout. If you have something like that then you need to ask yourself is it necessary? When was the last time you saw such a thing in a ‘Big Name’ novel? If it is necessary then make sure that you format it correctly and test, test, test. I also have not included information about creating an NCX file – this allows the user to jump between chapters using the five-way controller and makes those little lines on the progress bar. It is a good idea to have one of these, but an awful lot of books by the major publishers don’t, so for now see how you get on without one.

2 Comments

  1. There are various tools (just a Web search away) that will automate removal of the CSS style info, to prepare for adding the style code you want. Also, turning off indent for the first paragraph of a chapter is apparently not a right-or-wrong thing; in a quick review of my dead-tree bookshelf, I found non-indented, normally-indented, and mega-indented first paragraphs of chapters in a variety of well-known books.

  2. You are right, Stuart. I just didn't want to add yet another step in the process for those daunted by the whole thing. If you want to post a link or two of those you think are the best, feel free.

    As regards the indent I just checked a dozen (paper) books and they all had no indent first lines (should point out this is in the UK so maybe we do things differently over here).

Comments are closed.

Close Bitnami banner
Bitnami