View Single Post
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: 473
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