![]() |
#1 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 455
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Heading/Subtitle html coding best practice
The longer I do this, the more I find myself second guessing years of habit... I'm curious what best practice is for headings/subheadings: should the heading be in a separate element or should style differences be offset by a <br /> and the use of <span>s? Or does it not really matter?
For example: 1. The End of the Beginning My instinct would be to render this as: Code:
<p class="a"><span class="x">1.</span><br /> The End of the Beginning</p> Ironically, this flies in the face of most of my html instincts in almost any other context, as I tend not to use <span>s if I can just style the next largest element (e.g. <p>)... This inconsistency is inspiring my sudden moment of self-doubt... (Edit: to be clear, generally I'd be using an <h#> element, not <p>...) Last edited by ElMiko; 05-06-2025 at 06:03 PM. |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,615
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
I use the following format.
It allows me to style the heading and sub heading individually without the use of spans to divide the different values. Code:
<h2 title="16 - Target List">16.</h2> <p class="chapterh2">Target List</p> |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,445
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
For my purposes, if the chapter number and the subheading use similar CSS, I will use a <br/><span>...</span>. Otherwise, I will use the chapter number in it's own header and the subheader with it's own CSS and then use a title="" to have both in the ToC. If I don't use a subheader, the title would be used to add Chapter ( i.e. title="Chapter 1">1.< ) since I prefer to not have naked numbers in the ToC.
Code:
<h3 title="Chapter 1">1.</h3> Code:
<h3 title="1: The End of the Beginning">1.</h3> <p class="subheader">The End of the Beginning</p> |
![]() |
![]() |
![]() |
#4 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,809
Karma: 6000000
Join Date: Nov 2009
Device: many
|
And most importantly, using a h1-h6 tag to create the header tells accessibility software that it is in fact a header and not a normal paragraph. Use the right tags to properly indicate structure so that screen reading software can actually detect the structure.
Last edited by KevinH; 05-06-2025 at 07:07 PM. |
![]() |
![]() |
![]() |
#5 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 455
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Yup... this is what my gut is telling me, too. Damn all of you...
The TOC isn't quite as easy when they are separate elements, but that should be manageable with some regex. That moment of "Replace All", though, is always slightly anxiety-inducing... @KevinH: If I hide a sub-sub heading from TOC, but it uses <h#> element, does that negatively affect accessibility? |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,809
Karma: 6000000
Join Date: Nov 2009
Device: many
|
With newer versions of Sigil to can click to create a checkpoint (snapshot) in case you need to revert. Plus there are additional ReplaceAll tools that create a table showing you all of the proposed changes with some before and after context soyou knw wheter to keep each change or not.
|
![]() |
![]() |
![]() |
#7 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 455
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
@KevinH – So what you're saying is that maybe variable lookbehinds are not the only reason for me to abandon 0.7.2 and join the future?
*grumble, grumble, grumble* |
![]() |
![]() |
![]() |
#8 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,809
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Quote:
Using a heading tag to indicate something is a header helps A cessibility even if not part of the TOC. |
|
![]() |
![]() |
![]() |
#9 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,809
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Quote:
Just the ability to run plugins like epubcheck and have it fill the Validation Window, is worth it to me but to each their own. |
|
![]() |
![]() |
![]() |
#10 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,445
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Personally, I could never go back to the earlier versions of Sigil. I have gotten too used to the improvements over the years. If nothing else, I was burned several times by BookView's ability to generate garbage code before I just stopped using it.
|
![]() |
![]() |
![]() |
#11 | |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 455
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
Quote:
...except... ...when I'm editing verse. In that case, I break stanzas in WYSIWYG. It's basically the only thing I use ye olde Book View for (other than as another preview window for the css effects), but it's a big enough feature (either when editing a poetry collection or simply engaging with blockquoted poetry/music in prose) that breaking those lines in a pure html editor would be a drag. What's more, I've NEVER run into issues with it messing up the html—probably because my use-case, while critical to my workflow, is very, very narrow. From what I can see from scanning the User Guide, it looks like Page Edit fully replaces Book View and it's functionality... is that more or less right? |
|
![]() |
![]() |
![]() |
#12 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,809
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Yes, same basic functionality as the old BookView for live editing visually.
|
![]() |
![]() |
![]() |
#13 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 455
Karma: 65460
Join Date: Jun 2011
Device: Kindle
|
I've made the plunge. Someone please hold me...
|
![]() |
![]() |
![]() |
#14 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,445
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Be calm and edit on...
|
![]() |
![]() |
![]() |
#15 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,086
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I use the with <br /> method as it Generates the TOC with both the # and the text.
It also meets the accessibility reason to use <h# tags instead of P or Div If you want the text part Larger or smaller, just wrap that in a Span with the styling wanted. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Best practice for chapter heading images | Klip | Kindle Formats | 0 | 03-28-2019 07:23 AM |
Best practice to OCR and convert PDF to text or html or epub | crankypants | ePub | 15 | 12-14-2015 08:00 PM |
Best practice to convert framed HTML to e-reader readable format? | avid01 | Workshop | 12 | 06-07-2015 06:03 AM |
Best practice to import a HTML web pages to iBooks on same iOS device? | avid01 | Apple Devices | 5 | 04-24-2015 05:56 AM |
Kindle Coding Glitch - html/image problem | adam_omega | Amazon Kindle | 5 | 02-12-2011 07:24 PM |