|
|
Thread Tools | Search this Thread |
05-20-2014, 10:19 AM | #1 |
Zealot
Posts: 104
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?
|
05-20-2014, 11:12 AM | #2 |
frumious Bandersnatch
Posts: 7,515
Karma: 18512745
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> 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. |
05-20-2014, 11:58 AM | #3 |
Zealot
Posts: 104
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.
|
05-20-2014, 02:58 PM | #4 | |
Wizard
Posts: 1,539
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Code:
<h1 title="FRONTISPIECE"></h1> 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> Regards Rubén |
|
05-20-2014, 03:29 PM | #5 |
Zealot
Posts: 104
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.
|
05-21-2014, 12:22 AM | #6 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (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> Code:
hidden {display:none} |
05-21-2014, 02:12 AM | #7 |
Zealot
Posts: 104
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> Code:
.hidden {visibility:hidden;} |
05-21-2014, 03:24 AM | #8 |
frumious Bandersnatch
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
05-21-2014, 03:34 AM | #9 |
Zealot
Posts: 104
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.
|
05-21-2014, 07:54 AM | #10 |
Wizard
Posts: 1,539
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
|
05-21-2014, 10:13 AM | #11 |
Color me gone
Posts: 2,089
Karma: 1445295
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.
|
05-21-2014, 10:18 AM | #12 | |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
Anyway, this does work, and I can't think of a downside, even a potential one. Momentum alone should keep me using it. |
|
05-23-2014, 05:34 AM | #13 |
Scripler Project Lead
Posts: 19
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.
|
|
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 |