Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 05-20-2014, 10:19 AM   #1
Derek R
Connoisseur
Derek R began at the beginning.
 
Derek R's Avatar
 
Posts: 87
Karma: 20
Join Date: Jun 2011
Location: County Down, Northern Ireland
Device: none
Are 'empty' heading tags acceptable for generating a table of contents?

I usually generate the table of contents from <h1> tags. However, there are occasions when I don't want headings displaying at the top of particular sections in an ebook. For instance, I would want to avoid having a heading appear above the frontispiece in the xhtml file that I have created for that image. Rather than have <h1>FRONTISPIECE</h1>, for example, is it acceptable to simply have <h1></h1> with nothing between the container tags and then edit the toc to include 'Frontispiece' as the section title? Or is it bad practice to use tags in this way and, if so, what is the best alternative?
Derek R is offline   Reply With Quote
Old 05-20-2014, 11:12 AM   #2
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,166
Karma: 4792399
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
You don't need a heading tag for a TOC entry, it's enough with an "id" in any element, for instance:

Code:
<p class="dedication" id="ded">To my mother</p>
and then just use "...#ded" in the "src" attribute (I think that's the correct one) in the TOC file.

It's only automated tools which "need" heading tags to build the TOC for you, but if you are going to edit it anyway, you are not constrained by the tool's options.

EDIT: Or, more simple yet, if you want the TOC entry to point to the top of a file, you don't need the "id" at all.
Jellby is offline   Reply With Quote
Old 05-20-2014, 11:58 AM   #3
Derek R
Connoisseur
Derek R began at the beginning.
 
Derek R's Avatar
 
Posts: 87
Karma: 20
Join Date: Jun 2011
Location: County Down, Northern Ireland
Device: none
Thank you, Jellby. I stupidly forgot to mention that I am generating the table of contents in Sigil. However, your response clarified my thinking. I can generate the TOC initially with the h1 tags and then by using 'Edit Table Of Contents' I can add further items.
Derek R is offline   Reply With Quote
Old 05-20-2014, 02:58 PM   #4
RbnJrg
Evangelist
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 457
Karma: 318996
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Derek R View Post
I usually generate the table of contents from <h1> tags. However, there are occasions when I don't want headings displaying at the top of particular sections in an ebook. For instance, I would want to avoid having a heading appear above the frontispiece in the xhtml file that I have created for that image. Rather than have <h1>FRONTISPIECE</h1>, for example, is it acceptable to simply have <h1></h1> with nothing between the container tags and then edit the toc to include 'Frontispiece' as the section title? Or is it bad practice to use tags in this way and, if so, what is the best alternative?
Well, if you are working with Sigil then is a piece of cake what you want Just use (in the place you want):

Code:
<h1 title="FRONTISPIECE"></h1>
and after pressing Ctrl+T, you'll have a TOC entry with the name FRONTISPIECE.

So, what you need to do is to write with the global attribute "title" what you want to appear in the TOC. Examples:

Code:
<h1 title="This is a TOC entry"></h1>
<h2 title="Another TOC entry"></h2>
and so on Of course, tags <h1..h6> can be empty.

Regards
Rubén
RbnJrg is offline   Reply With Quote
Old 05-20-2014, 03:29 PM   #5
Derek R
Connoisseur
Derek R began at the beginning.
 
Derek R's Avatar
 
Posts: 87
Karma: 20
Join Date: Jun 2011
Location: County Down, Northern Ireland
Device: none
Thank you, Rubén - I've tested that and it works a treat - a handy tip indeed.
Derek R is offline   Reply With Quote
Old 05-21-2014, 12:22 AM   #6
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 6,173
Karma: 9881980
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch (Wifi only)
Wouldn't conversion be likely to delete these empty tags? Probably not a big deal, but I use
Code:
<h1 class="hidden">This is a ToC entry</h1>
with css of
Code:
hidden {display:none}
eschwartz is offline   Reply With Quote
Old 05-21-2014, 02:12 AM   #7
Derek R
Connoisseur
Derek R began at the beginning.
 
Derek R's Avatar
 
Posts: 87
Karma: 20
Join Date: Jun 2011
Location: County Down, Northern Ireland
Device: none
Another excellent tip - thank you, eschwartz. That css was not in my armoury until now. It led me to discover that the following could also be used:

Code:

Code:
<h1 class="hidden">This is a ToC entry</h1>
css:

Code:
.hidden {visibility:hidden;}
which will hide the text between the tags but take up the space of the <h1> element.
Derek R is offline   Reply With Quote
Old 05-21-2014, 03:24 AM   #8
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,166
Karma: 4792399
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Derek R View Post
Code:
.hidden {visibility:hidden;}
which will hide the text between the tags but take up the space of the <h1> element.
But "visibility" is not among the CSS properties required for ePub 2.0.1, so don't be surprised if it is not supported by some reader.
Jellby is offline   Reply With Quote
Old 05-21-2014, 03:34 AM   #9
Derek R
Connoisseur
Derek R began at the beginning.
 
Derek R's Avatar
 
Posts: 87
Karma: 20
Join Date: Jun 2011
Location: County Down, Northern Ireland
Device: none
Okay - thanks - then sticking to "display: none" seems to be the safer bet, although on devices where "visibility" isn't supported presumably the content of the container tags would display, which wouldn't be entirely disastrous.
Derek R is offline   Reply With Quote
Old 05-21-2014, 07:54 AM   #10
RbnJrg
Evangelist
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 457
Karma: 318996
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by eschwartz View Post
Wouldn't conversion be likely to delete these empty tags?
I don't think that but even so, the TOC will remain unchanged. You can be sure that the attribute "title" will be serviceable to generate a TOC.
RbnJrg is offline   Reply With Quote
Old 05-21-2014, 10:13 AM   #11
mrmikel
Book Twiddler
mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.mrmikel ought to be getting tired of karma fortunes by now.
 
Posts: 2,056
Karma: 1444487
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
On some readers, hidden text will hide the text alright, but if it is in the middle of a line, it will leave a blank space and cause text to be shoved over to the right edge. I try to avoid this for my old PRS-300.
mrmikel is offline   Reply With Quote
Old 05-21-2014, 10:18 AM   #12
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 6,173
Karma: 9881980
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch (Wifi only)
Quote:
Originally Posted by RbnJrg View Post
I don't think that but even so, the TOC will remain unchanged. You can be sure that the attribute "title" will be serviceable to generate a TOC.
I think I remember discussion about empty paragraph tags used for scene breaks instead of css margins being inadvisabe for this reason. I would try to avoid breaking things down the line... someone else might be inconvenienced later on.

Anyway, this does work, and I can't think of a downside, even a potential one. Momentum alone should keep me using it.
eschwartz is offline   Reply With Quote
Old 05-23-2014, 05:34 AM   #13
Abekonge
Scripler Project Lead
Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.Abekonge has met Morla.
 
Abekonge's Avatar
 
Posts: 10
Karma: 19304
Join Date: May 2014
Location: Copenhagen, Denmark.
Device: Gameboy Color
I always use <h1 style="display:none">Toc-entry title</h1> - works like a charm.
Abekonge is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating Table of Contents ldrover Calibre 0 06-21-2012 04:24 PM
Generating a Table of Contents ebookn00b Kindle Formats 14 04-27-2012 04:22 AM
Generating a rough "table of contents" Vanguard3000 Calibre 5 01-09-2011 10:31 PM
Table of Contents not generating Amalthia Calibre 2 12-19-2010 08:15 PM
Turning H2 tags into a Table of Contents? Amalthia Calibre 9 04-23-2009 01:24 PM


All times are GMT -4. The time now is 02:28 AM.


MobileRead.com is a privately owned, operated and funded community.