Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 05-06-2025, 05:57 PM   #1
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
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>
where "a" establishes the alignment/margins of the element and the style of the subheading, and "x" extablishes the style of the heading.

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.
ElMiko is offline   Reply With Quote
Old 05-06-2025, 06:15 PM   #2
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
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>
Karellen is offline   Reply With Quote
Advert
Old 05-06-2025, 06:20 PM   #3
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
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>
If necessary, regex is very helpful in generating the title element.
DNSB is offline   Reply With Quote
Old 05-06-2025, 06:44 PM   #4
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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.
KevinH is online now   Reply With Quote
Old 05-06-2025, 06:45 PM   #5
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
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?
ElMiko is offline   Reply With Quote
Advert
Old 05-06-2025, 06:48 PM   #6
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
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.
KevinH is online now   Reply With Quote
Old 05-06-2025, 06:54 PM   #7
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
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*
ElMiko is offline   Reply With Quote
Old 05-06-2025, 07:11 PM   #8
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,809
Karma: 6000000
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by ElMiko View Post

@KevinH: If I hide a sub-sub heading from TOC, but it uses <h#> element, does that negatively affect accessibility?
You control what is in TOC and can select which heading to include or not via the TOC Editor. Using the title attribute in heading tags controls the title.

Using a heading tag to indicate something is a header helps A cessibility even if not part of the TOC.
KevinH is online now   Reply With Quote
Old 05-06-2025, 07:15 PM   #9
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,809
Karma: 6000000
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by ElMiko View Post
@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*
As long as you are not heavily reliant of BookView and can use Sigil's Preview (and PageEdit) then updating Sigil should be a huge improvement. Just one that will have a learning curve as you have waited so long.

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.
KevinH is online now   Reply With Quote
Old 05-06-2025, 08:12 PM   #10
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
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.
DNSB is offline   Reply With Quote
Old 05-06-2025, 11:01 PM   #11
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 455
Karma: 65460
Join Date: Jun 2011
Device: Kindle
Quote:
Originally Posted by DNSB View Post
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.
Overwhelmingly, I edit in html...

...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?
ElMiko is offline   Reply With Quote
Old 05-06-2025, 11:06 PM   #12
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,809
Karma: 6000000
Join Date: Nov 2009
Device: many
Yes, same basic functionality as the old BookView for live editing visually.
KevinH is online now   Reply With Quote
Old 05-07-2025, 12:19 AM   #13
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 455
Karma: 65460
Join Date: Jun 2011
Device: Kindle
I've made the plunge. Someone please hold me...
ElMiko is offline   Reply With Quote
Old 05-07-2025, 02:43 AM   #14
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
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...
DNSB is offline   Reply With Quote
Old 05-07-2025, 07:18 PM   #15
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
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.
theducks is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 01:50 PM.


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