Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 01-16-2026, 01:38 PM   #1
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 67
Karma: 10
Join Date: Nov 2025
Device: none
Is it good practice to have <p> in <h>?

Is it good practice to have <p> in <h>?

I have benn using this when I didn't know better.
Now I am revisiting my old project, and found this:

Code:
<div style="text-align: center;">

<h2>
<p>奥克迪尼的恐怖</p>
<p>The Horror at Oakdeene</p>
</h2>

<p>译者:张三</p>
</div>
Is this just bad practice or can cause some serious problems?
icearch is offline   Reply With Quote
Old 01-16-2026, 02:19 PM   #2
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: 9,252
Karma: 6565382
Join Date: Nov 2009
Device: many
According to the html spec of allowable children of an h1-h6 tag, it includes "phrasing content tags" and things like div and p tags are discouraged.
KevinH is offline   Reply With Quote
Advert
Old 01-16-2026, 02:29 PM   #3
RbnJrg
Wizard
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: 1,906
Karma: 8987599
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by icearch View Post
Is it good practice to have <p> in <h>?

I have benn using this when I didn't know better.
Now I am revisiting my old project, and found this:

Code:
<div style="text-align: center;">

<h2>
<p>奥克迪尼的恐怖</p>
<p>The Horror at Oakdeene</p>
</h2>

<p>译者:张三</p>
</div>
Is this just bad practice or can cause some serious problems?
If you need that layout in your titles, then use <span> tags instead of <p>. And give those spans the property "display: block" (and all others styles you wish).
RbnJrg is offline   Reply With Quote
Old 01-16-2026, 02:58 PM   #4
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,749
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Another approach could be...

PHP Code:
<h2 title ="Chapter 1 - The Horror at Oakdeene">Chapter 1</h2>
<
class="chapterh2">The Horror at Oakdeene</p
Karellen is online now   Reply With Quote
Old 01-16-2026, 04:53 PM   #5
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,448
Karma: 20534347
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Or….

Code:
h2      {all your styling}
h2 span {display:block; even more different styling}


<h2>Chapter 1 <span>The Horror at Oakdeene</span></h2>
Sigil will read all of that when creating the ToC without the need of title= and they can be styled completely separately. You can even insert images before, after, or between!

Lots of different ways to achieve the visual result, a few of them achieve both visual and semantic effects.
Turtle91 is offline   Reply With Quote
Advert
Old 01-16-2026, 05:19 PM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 81,656
Karma: 150265991
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by icearch View Post
Is it good practice to have <p> in <h>?

I have benn using this when I didn't know better.
Now I am revisiting my old project, and found this:

Code:
<div style="text-align: center;">

<h2>
<p>奥克迪尼的恐怖</p>
<p>The Horror at Oakdeene</p>
</h2>

<p>译者:张三</p>
</div>
Is this just bad practice or can cause some serious problems?
epubcheck flags your <p> inside an <h2> as an error.
JSWolf is offline   Reply With Quote
Old 01-16-2026, 05:22 PM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 81,656
Karma: 150265991
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Karellen View Post
Another approach could be...

PHP Code:
<h2 title ="Chapter 1 - The Horror at Oakdeene">Chapter 1</h2>
<
class="chapterh2">The Horror at Oakdeene</p
<h2 title is only useful in Sigil.
JSWolf is offline   Reply With Quote
Old 01-16-2026, 05:59 PM   #8
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,749
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by JSWolf View Post
<h2 title is only useful in Sigil.
Please explain why? Is this a Sigil only feature?
I find it very useful in Calibre, especially when generating the TOC as it saves a ton of work renaming the chapters in the TOC.
(but I suppose you are going to tell me that I shouldn't be renaming the toc??)
Karellen is online now   Reply With Quote
Old 01-16-2026, 06:17 PM   #9
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 81,656
Karma: 150265991
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Karellen View Post
Please explain why? Is this a Sigil only feature?
I find it very useful in Calibre, especially when generating the TOC as it saves a ton of work renaming the chapters in the TOC.
(but I suppose you are going to tell me that I shouldn't be renaming the toc??)
Why would you not show the chapter's title in the actual chapter?
JSWolf is offline   Reply With Quote
Old 01-16-2026, 06:30 PM   #10
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: 9,252
Karma: 6565382
Join Date: Nov 2009
Device: many
title is a global attribute and therefore is a valid attribute for h1-h6 tags. There is nothing Sigil specific in its use.

Sigil does have an automatic TOC generator and gives the title attribute priority in constructing a toc. I am sure calibre can do something similar.

Last edited by KevinH; 01-16-2026 at 06:32 PM.
KevinH is offline   Reply With Quote
Old 01-16-2026, 06:37 PM   #11
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,749
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by JSWolf View Post
Why would you not show the chapter's title in the actual chapter?
What makes you say it's not?
It is clearly shown in the code I posted that it is there.
Anyway, I don't think this is going anywhere useful, so moving on.
Karellen is online now   Reply With Quote
Old 01-16-2026, 09:18 PM   #12
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: 49,612
Karma: 174632684
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by JSWolf View Post
Why would you not show the chapter's title in the actual chapter?
Have you never run into a book where the title is an image? I add the title="whatever" to the <h tag so I don't have to manually edit the ToC. It also helps when I just want the chapter in the ToC to read "Chapter 1" while the displayed chapter header would be "1".
DNSB is offline   Reply With Quote
Old 01-16-2026, 11:17 PM   #13
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 67
Karma: 10
Join Date: Nov 2025
Device: none
Thanks for all your answers and solutions. After looking into my book, I found out that I don't need block in <h for now. So I just use <br/ to break the line.

Like this:
Code:
<div style="text-align: center;">

<h2>
姐妹之城<br/>
The Sister City
</h2>

<p class="no-ss">译者:李四</p>
</div>
I do think this is sufficient enough, and a more tighter line spacing is more visually pleasing too.
icearch is offline   Reply With Quote
Old 01-16-2026, 11:24 PM   #14
icearch
Connoisseur
icearch began at the beginning.
 
Posts: 67
Karma: 10
Join Date: Nov 2025
Device: none
As for using title= attributes in <h , I use it when I need to auto generate Nav and Toc but don't want visible headings in that page.
icearch is offline   Reply With Quote
Old Yesterday, 06:56 AM   #15
RbnJrg
Wizard
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: 1,906
Karma: 8987599
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by icearch View Post
As for using title= attributes in <h , I use it when I need to auto generate Nav and Toc but don't want visible headings in that page.
What pages? But whatever, use the property "display: none" to hide the element you want (and even so, title="..." still will be honored). You also coud be using "visibility: hidden", but with this last property, the space ocuped by the element will be visible.
RbnJrg is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best Practice tamhas Calibre Companion 23 05-13-2016 11:18 AM
Best Practice for <title>? Doctor T Sigil 5 01-21-2015 02:05 PM
Good practice for packaging / folder management with Sigil wdaly Sigil 4 03-08-2013 03:56 PM
good practice question / re-converting affa Library Management 3 06-22-2012 06:33 AM
restrictive practice nobicus Sony Reader 14 09-30-2008 12:27 PM


All times are GMT -4. The time now is 07:30 PM.


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