![]() |
#1 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Apr 2019
Location: Brazil
Device: Kindle Paperwhite
|
Chapter formatting
Hi, group, how are you? I am a graphic designer who is migrating to the "literary" mobile world. I have read a lot about html and css for epub and mobi, but I have a question that I still can not solve: When a chapter page has two elements: chapter number and, below, the chapter title, which hierarchy of headings ? I could start with a <h3> for the chapter number and then insert a <h1> in the title? the goal is to leave this larger than the first.Something like that:
Chapter 1 The life of Brian This is my first post, and I could not find this question here, so if it already exists, I apologize for repeating a post. Thank you all! |
![]() |
![]() |
![]() |
#2 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,825
Karma: 168802811
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
As a quick and dirty example (the first line is from the text, the two classes are in the stylesheet: Code:
<h3 class="chapternum">Chapter 1<br/><span class="bigc15">The Ending of the Beginning</span></h3> .chapternum { font-size: 1.5em; margin-top: 2em; margin-bottom: 1.5em; margin-right: 0; margin-left: 0; page-break-after: avoid; text-align: center; font-weight: bold; } .bigc15 { font-size: 1.5em; } Also note that this is for epub. Mobi should work much the same but oddities will occur. Last edited by DNSB; 05-01-2019 at 12:40 AM. |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,905
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 also use DNSB's method.
This has the advantage of being perfect for the TOC (from header) tools to include both pieces as a single entry (also on a single line) Forget the old "Use Headers for style" Use them for TOC indent levels h3 chapter h2 part h1 if you need something as a wrapper. I leave the books title at the same level as the outer layer used |
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Apr 2019
Location: Brazil
Device: Kindle Paperwhite
|
![]()
Thanks, "DNSB" and "theducks" for the tips.
I tested in Sigil and Kindle Previewer and it's OK. One mor question: can I change <h3> to <h1> for a better HTML semantics? Best, Pedrovic |
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
Does anyone ever use the section tag? I like its semantics, how it contains the chapter (i.e., has an end section tag) rather than having an h tag merely start the chapter. I have no idea what the epub spec says about it.
https://stackoverflow.com/questions/...ection-and-div |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
|
![]() |
![]() |
![]() |
#7 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,905
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'm with Hitch. I only use H#'s to aid in using the TOC tool. No other reason.
If you want size, use the CSS (and maybe a Span to raise or lower the size of part of the title) |
![]() |
![]() |
![]() |
#8 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,312
Karma: 20171571
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
|
The <h?> tags are more semantically correct when used to define/differentiate what level 'header' you are using. You can style your headers however way you wish, or no way at all. Some devices might apply default styles to a header when that device doesn't use the publisher's css. As mentioned previously, some programs like Sigil and Calibre Editor can auto create TOC based on the header tags.
I use them in a heirarchy like this: Spoiler:
I also use css similar to the example provided by DNSB, but mine relies a little more on the rules of CSS to define styling rather than giving everything a class name. This approach is perfectly valid and, IMO, provides a little cleaner html code: Spoiler:
I don't particularly use the <section> tag. I haven't needed it - but I haven't really gotten into ePub3 spec. I break up each chapter into its own file so really don't need another tag to say it's a chapter. I do use <div> tags to give special formatting to a section of the file. To me that serves the same purpose. Spoiler:
|
![]() |
![]() |
![]() |
#9 | |
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Hitch |
|
![]() |
![]() |
![]() |
#10 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
Hitch, I think he's currently relying on the built in formatting of the h1 and h3 tags, with h1 being bigger than h3. In his example the smaller text is h3 and precedes the larger h1 text. But now that you've revealed the wizard behind the curtain (CSS) he's asking if he can change that h3 to an h1.
|
![]() |
![]() |
![]() |
#11 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,825
Karma: 168802811
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
I might ask why using h1 instead of h3 would be better HTML semantics? They should be used for heading levels from h1 to h6. In my case, consistency says a single book would not get a <h1>, a book without parts would not get a <h2>, etc. Last edited by DNSB; 05-01-2019 at 10:09 PM. |
|
![]() |
![]() |
![]() |
#12 |
Obsessively Dedicated...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,202
Karma: 34984330
Join Date: May 2011
Location: JAPAN (US expatriate)
Device: Sony PRS-T2, ADE on PC
|
I always use h1 for the book title. Then descend as needed. If it is an omnibus, the individual book titles get to be h2 and their chapters are h3. If it is a standard novel with chapters or a short story collection, those are often assigned as h3 also. I have never gone deeper than h4, and that is seldom, because I only do simple fiction, and that very rarely has sub-chapters.
You can use the hx with a title: tag if you want the name to appear differently in the TOC than it appears on the page, or even set the hx to display:none and then create your displayed heading text(s) with <p>s or <div>s. |
![]() |
![]() |
![]() |
#13 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
pedrovic, putting it all together/cutting to the chase, I think the way to do it is as DNSB originally outlined, with a br and span inside the h3 tag and using classes to control the appearance/formatting.
|
![]() |
![]() |
![]() |
#14 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 682
Karma: 4568205
Join Date: Jan 2010
Location: Sweden
Device: Kobo Forma
|
This is something I have been thinking about lately (and I have done in with two separate h# but wondering what best practice is), thank you pedrovic for asking and all you others for great responses!
![]() If you do it like DNSB describes, how do you adjust the space between the two lines (besides putting multiple <br/>s)? (line-height could be used if the two lines are short enough to never use multiple lines on the device) Also, what is the usuability to have the cover as a heading? I use headers as a way to get a toc, and for me, the cover shouldn't be there. What am I missing? |
![]() |
![]() |
![]() |
#15 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Apr 2019
Location: Brazil
Device: Kindle Paperwhite
|
Hello, thank you all for the comments.
![]() I meant that, from the little I understand, it is not good practice to put a <h3> before a <h1>, for hierarchical reasons. So I was in doubt about this because, in some printed books, it is common to have a smaller chapter number preceded by its title, according to the example I posted. And I suggested switching <h3> to <h1> to have more subtitle options in the text body, you know? Best, Pedrovic |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with Chapter seperators (lines underneath chapter headings) | indieauthor83 | Sigil | 9 | 06-23-2017 06:01 AM |
Next chapter in the saga of poor ebook formatting | Joques | General Discussions | 140 | 05-13-2015 05:31 PM |
xpath to insert chapter breaks - but chapter name cut off ? | Rob557 | Conversion | 2 | 03-06-2014 06:59 AM |
Formatting Chapter Breaks? | NVash | Calibre | 3 | 12-09-2010 05:09 AM |
Formatting error causes a whole chapter to be unreadable | kjturner71 | Kobo Reader | 3 | 11-08-2010 04:50 PM |