|
|
#1 |
|
Connoisseur
![]() 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> |
|
|
|
|
|
#2 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
|
|
|
| Advert | |
|
|
|
|
#3 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,906
Karma: 8987599
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
|
|
|
|
|
|
|
#4 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,749
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Another approach could be...
PHP Code:
|
|
|
|
|
|
#5 |
|
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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>
Lots of different ways to achieve the visual result, a few of them achieve both visual and semantic effects. |
|
|
|
| Advert | |
|
|
|
|
#6 | |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
|
|
|
|
|
|
|
#7 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
|
|
|
|
|
|
#8 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,749
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
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??) |
|
|
|
|
|
#9 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
Why would you not show the chapter's title in the actual chapter?
|
|
|
|
|
|
#10 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
|
|
|
|
|
#11 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,749
Karma: 9501034
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
|
|
|
|
|
|
#12 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 49,612
Karma: 174632684
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
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".
|
|
|
|
|
|
#13 |
|
Connoisseur
![]() 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> |
|
|
|
|
|
#14 |
|
Connoisseur
![]() 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.
|
|
|
|
|
|
#15 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,906
Karma: 8987599
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
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.
|
|
|
|
![]() |
|
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 |