View Full Version : Help me with some concepts with tags/class for epub


FatDog
06-16-2012, 12:54 AM
I have 3 long stories by the same author in txt format.

My goal is to wrap enough XHTML tags so that I can shove it into Sigil and produce a halfway decent epub.

I have wrapped all the paragraphs with "p" tags.

Now I understand I need to find where it says "Chapter NN" and wrap "h2 class="chapter" around them. This will allow me to use CSS to center/bold/do interesting things and the TOC can be generated automatically.

Since I might combine all 3 stories (40-90 chapters each) should these be "h3" tags so I can use "h2" for the titles?

What about "div" tags? I have seen some examples, but not sure where I should put them or how many "class=aaa". Where should I put them and what are they used for?

And there are separations like "* * *" sprinkled throughout. What tags should I use for these?

What other markup should I use? Is there a good guide you can send me to other than "here are all the tags you CAN use..." with no instructions on why you should use each?

Jellby
06-16-2012, 06:27 AM
You can use <h1> for each story, and <h2> for the chapters. Some people like using <h1> for the book title instead, but I find it unnecessary (I don't include the book title as an item in the TOC, anyway). But you could also use <h2> and <h3>, or <h5> and <h6>...

<div> are for marking generic blocks. They don't have any default styling, so any formatting you want to apply to them must be done with CSS, and for every different kind, you use a different class. Which ones to use depends on your book. The separations using "* * *" are a good candidate for a <div>:

<div class="scene_break">* * *</div>

and then with CSS you make it centered, and with some top and bottom margins. I often use <div>s for centered blocks, signatures, poetry...

As for other tags, I guess the main one is <blockquote>, which you can use if there are letters or quoted fragments in your books. And there's inline tags, such as <i>, <b>, or the generic <span>.

Toxaris
06-16-2012, 07:52 AM
Is it me or am I the only one who rather uses a classed paragraph style instead of the blockquote tags? I find it more consistent if I use paragraphs only with a different style.

FatDog
06-16-2012, 11:23 AM
Thank you for your great response.

The author does have some email embedded inside the story and I have just wrapped "pre"formatted tags around these so they dont word-wrap. But blockquote tags would be better?

(Part of my problem is I have been doing some HTML5/CSS3 stuff at work, then when trying to convert these files to epub I found some tags that actually said "<chapter>", and "<footnote>" and "<dedication>", then I learned it was for the DocText system and not compatible with xHTML. So I am in "tag hell" at the moment and need a basic ePub cheat sheet that just focuses on the content markup. ).

dwig
06-16-2012, 11:24 AM
...
And there are separations like "* * *" sprinkled throughout. What tags should I use for these?
...

There are several issues to consider. If you are working from a very typical TXT format ebook and you are creating and HTML or ePub version with the commonly preferred "no leading between paragraphs and indented first line" style then:


omit the line with the asterisks
style (class) the following <p> so that it has a top-margin, generally 1em


This leaves a blank line between the two paragraphs between which the asterisks had been placed. Some people prefer that the following <p> also no be indented.

DaleDe
06-16-2012, 12:02 PM
Thank you for your great response.

The author does have some email embedded inside the story and I have just wrapped "pre"formatted tags around these so they dont word-wrap. But blockquote tags would be better?

(Part of my problem is I have been doing some HTML5/CSS3 stuff at work, then when trying to convert these files to epub I found some tags that actually said "<chapter>", and "<footnote>" and "<dedication>", then I learned it was for the DocText system and not compatible with xHTML. So I am in "tag hell" at the moment and need a basic ePub cheat sheet that just focuses on the content markup. ).

Those are supported in ePub 3 so you are just ahead of the curve :). To maintain almost CSS compatibility I would suggest you change them to something like:
<chapter> to <h2 class="chapter">
<footnote> to <p class="footnote">
<dedication to <p class="dedication">
etc.
This will make the CSS changes easy and match the look of the ePub 3 book. This can be done using a simple search and replace in a text editor. Sigil will fix the trailing tags when you add it in.

Dale

Jellby
06-17-2012, 05:17 AM
Is it me or am I the only one who rather uses a classed paragraph style instead of the blockquote tags? I find it more consistent if I use paragraphs only with a different style.

A blockquote can contain many kinds of paragraphs and blocks, I certainly consider adding a <blockquote> is easier and helps with consistency. Perhaps you didn't know a <blockquote> can contain <p> and <div> tags too?:

<p>Normal text ...</p>

<blockquote>
<p class="salutation">My dear Someone,</p>
<p>Normal letter text...</p>
<p>Normal letter text...</p>
<p>Normal letter text...</p>
<p class="center">Love</p>
<div class="signature">Myself</p>
</blockquote>

<p>Normal text...</p>

Would you rather add different styles for "salutation", "center" and "signature" inside or outside a blockquote? And here:

<p>Normal text...</p>

<blockquote>
<p>Long quotation...</p>
<p>Long quotation...</p>
<p>Long quotation...</p>
</blockquote>

<p>Normal text...</p>

Would you rather add a top margin to the first paragraph and a bottom margin to the last paragraph in the quote?

Toxaris
06-17-2012, 06:25 AM
I did know you can have that inside a blockquote, but for me it does not add anything. I can easily use multiple styles (it is cascading after all) and the margins I have already in styles. So, for me it does not really add anything. But I understand that others use it and why.

HarryT
06-17-2012, 11:05 AM
A slightly oblique question, but do you actually need to do this? Does the author not make these stories available for download in a more "modern" format, such as HTML, ePub, or Mobi?

FatDog
06-18-2012, 03:46 PM
A slightly oblique question, but do you actually need to do this?

No. I discovered a disk-case of CD's with .txt files from 10-15 years ago and I am trying to "curate" them. I'm having fun learning ePub, HTML5, and I am using the project to force me to re-train my fingers to use a MacBook.