Friday, August 6, 2010

Six tags you need to create an ePUB

I've been talking for some time about actually giving instruction on how to create your eBook and now it's time to get busy and do it. Most instruction sets I've found tell you everything you never wanted to know about xhtml before you ever get around to creating a book, but there are really only six xhtml tags that you need to know in order to set up your content. We're going to start right off by creating one.

First use a text editor. The simplest text editor you can get is best to start with. I use Windows Notepad for mine. You use a text editor instead of a word processor (Microsoft Word) because it does not automatically reformat text as you type. The first tag you will need is the <html> tag. That starts your document and at the very end of the document you will finish with the </html> closing tag. All tags come in pairs. The open tag is just the brackets and tagname. The closing tag includes a slash (/).

Second, the <head> tag encloses information about your book, not the book itself. Nested inside the head is the <title> tag. This is where you put the title of your book. We'll get to more sophisticated ways of using the header information in the future, but right now your file should look like this:

<html>
<head>
<title>My Book</title>
</head>
</html>


Even when you are creating complex books with hundreds of sections and sub-chapters, you will have these tags at the beginning of each xhtml or html document.

Now you are ready to put in your content. There are only three tags needed for the content. The beginning tag is <body>. It doesn't close until just before the closing tag. Everything else in your book is inside the body tag.

<h1> is the next tag and is used for your chapter heads. There are six different levels of heading available, but by-and-large it is safest and easiest to use the h1 tag for the top level of your chapter. Put the chapter name, number, or title after the opening h1 tag and then close the heading with the </h1> tag. Remember, tags (almost) always come in pairs.

Finally, each paragraph of your story must be enclosed in a <p></p> tag set. Here is a quick tip: In your word processor, before you put the text for your story in the text editor, do a search and replace for all paragraph breaks and replace them with the p tag. If you use a double-return to create space between paragraphs in your manuscript, replace the two together. For example: Replace ^p^p with </p>^p<p>. Then copy and paste your manuscript after the headline. It should come out looking like this.

<html>
<head>
<title>My Book</title>
</head>
<body>
<h1>Chapter 1</h1>
<p>First paragraph goes here.</p>
<p>Second paragraph goes here.</p>
</body>
</html>


Save the file as an html file (with the .html extension) When you look at the file in your directory, if it says .txt at the end of the name, rename the file with the extension .html. Ignore all warnings about whether it will be readable. Finally, double-click on the icon for your new book and take a look at it. It will open in your default Web browser. It won't look pretty, but it will be accurate, and you created this little Web page with just six tags. Easy, wasn't it?

Chapter 1

First paragraph goes here.

Second paragraph goes here.


In the next lesson, we'll create the two files that need to be included in your eBook and package it up so you can view it in your reader.

1 comment:

  1. What an awesome and totally useful post! Thanks!

    ReplyDelete