11-21-2022, 12:56 AM | #1 |
Wizard
Posts: 1,163
Karma: 4917718
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
<caption> In Tables
Hello all,
I am a bit stumped with the <caption> tag used in a table. My epub is v3.0 I am adding the <caption> tag as follows: Spoiler:
But when I run EPUBCheck v0.2.4 by Doitsu, I get the following error.... PHP Code:
https://developer.mozilla.org/en-US/...lement/caption Can anybody see what the problem is? Thank you |
11-21-2022, 01:00 AM | #2 |
Wizard
Posts: 1,163
Karma: 4917718
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Oh, if I had only waited a couple more minutes before posting...
I figured it out. Only a single <caption> tag is allowed. Need to use <br/> for extra lines |
11-21-2022, 10:05 AM | #3 |
Guru
Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
|
It's interesting that neither the w3, mozilla, nor the spec, itself, specifically mentions that there can be only one:
https://www.w3schools.com/tags/tag_caption.asp https://developer.mozilla.org/en-US/...lement/caption https://html.spec.whatwg.org/multipa...aption-element Reading the text closely enough implies it, but it would have been nice if they'd have mentioned it. Good catch. Of course, it looks like you can put all kinds of formatting in the <caption></caption> pair. |
11-21-2022, 12:32 PM | #4 |
A Hairy Wizard
Posts: 3,119
Karma: 18727091
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
But anyone with a single lick of culture knows: "There can be only one."
|
11-21-2022, 12:48 PM | #5 | ||||
Grand Sorcerer
Posts: 6,553
Karma: 84810789
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
|
Quote:
Quote:
Quote:
Quote:
|
||||
11-22-2022, 02:32 PM | #6 |
the rook, bossing Never.
Posts: 11,589
Karma: 87456643
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
Things either have a caption or not. It's logical if you want newlines in a caption that you use <br/>, but then I've been using HTML since 1990s and programming many years earlier.
I'd guess the people writing the spec never imagined anyone adding more than one caption to one object. Specs are usually written by experts and reviewed by experts and rarely involve new or less expert users. It used to hurt my head reading Telecom specs and "Rainbow book" specs (different aspects used different colours). Last edited by Quoth; 11-22-2022 at 02:35 PM. |
11-22-2022, 11:08 PM | #7 | |||
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
If you insist on using <caption>, you could use <p>s (or any other markup) inside like:
Code:
<table> <caption> <p class="tabletitle">LSAT-560467-S</p> <p class="tabletitle">DATA TRANSCRIPT 463/511-001</p> <p class="tabletitle">SUBJECT SITE: 231.957 (North-eastern seaboard: CT, NY, NJ)</p> </caption> [... Rest of table here...] </table> Code:
<table> <caption>LSAT-560467-S<br/>DATA TRANSCRIPT 463/511-001<br/>SUBJECT SITE: 231.957 (North-eastern seaboard: CT, NY, NJ)</caption> [... Rest of table here...] </table>
- - - Side Note: But I've had trouble with <caption> across devices in the past, especially trying to move to top/bottom using CSS's caption-side. See my posts in: Personally, I still use an external <div> and/or <p>: Code:
<p class="tabletitle"></p> <table></table> <div class="caption"> <p class="caption"></p> </div> This:
Yes, it doesn't get some of those Accessibility goodies with full HTML markup, but it works across everything... - - - Quote:
You can use all the fancy markup you want inside of a <caption>... <p>, <span>, <i>/<em>, whatever. It's the same as a <td> or <th>. You can use those tags bare, or you could stick extra markup inside those cells... Quote:
In HTML5, it seems like <caption> is intended to be used only as a "Title" of the table. Then HTML5 promotes using <figure> + <figcaption> for an actual caption (or other info). For example: Code:
<figure> <table> <caption>LSAT-560467-S</caption> [... Rest of table here...] </table> <figcaption> <p class="caption">* An actual caption with extra info goes here.</p> </figcaption> </figure> Side Note #1: Similar to me avoiding <caption>, I wouldn't be using much <figcaption> either... See my post in: Older devices wouldn't be able to render the markup well, so you might get odd bugs. Side Note #2: What's with HTML's "poorly named" <caption>? Probably just ancient/legacy pre-HTML5 table stuff. I don't feel like digging through the ol' HTML specs, but I'm betting there was a ton of non-standard crap going on in there, and people were using it in all sorts of horrible ways. Side Note #3: Why is only 1 <caption> per table important? Because it generates a unique name for the <table> in ARIA + the Accessibility Tree. Quote:
Similar to <summary>, which is only allowed as a first child in <details>. Last edited by Tex2002ans; 11-22-2022 at 11:22 PM. |
|||
11-22-2022, 11:36 PM | #8 | |
Wizard
Posts: 1,163
Karma: 4917718
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Quote:
I'll add that little trick to my cheat sheet of code. I'll have a read through your links. Thanks for the informative post |
|
11-23-2022, 12:04 AM | #9 | |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
No problem.
Quote:
There are plenty of other "table Accessibility" things you can do that would bring much more benefit, like tagging/marking your columns/rows correctly! I think that'll be much more important than tying a title/caption to the <table> instead of just having them floating nearby. |
|
11-23-2022, 12:17 AM | #10 | |
Wizard
Posts: 1,163
Karma: 4917718
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Quote:
I used the caption on a Libra2, and that seemed to work quite well. No problems that I can see and all displayed and formatted correctly. But I can understand that there may be other ereaders where it won't work. I thought I did. Did you spot something wrong in my code snippet in my first post? I am happy to be educated if there is an error there (apart from the caption) |
|
11-23-2022, 12:55 AM | #11 | |||
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
For tables, I think the most important things are:
This means Text-to-Speech can read the cells correctly + the tables will follow all user preferences (font size, color, background, ...). Then, you can do some visual upgrades:
That's the important points for any and all formats. And that would get you like 98%+ of the way there. Then, and only then, would I begin worrying about further HTML(5) markup like <figcaption>, etc. - - - Side Note: Also, I'm not sure if you were aware... MobileRead has a [CODE] tag. You accidentally shoved your code inside of a [PHP] tag. - - - Quote:
If you are putting it up for sale in an actual store (Amazon, B&N, etc.), you have to be a lot more careful. Quote:
One tweak I would do though is... I tend keep my <th> + <td> bare, making it WAY easier to read. (Plus, you don't need to do all that <p class="noindent"> shenanigans.) Before: Code:
<th><p class="noindent">NO.</p></th> <th><p class="noindent">TIME/EST</p></th> <th><p class="noindent">LOC</p></th> <th><p class="noindent">READING</p></th> Code:
<th>NO.</th> <th>TIME/EST</th> <th>LOC</th> <th>READING</th> Last edited by Tex2002ans; 11-23-2022 at 01:06 AM. |
|||
11-23-2022, 01:12 AM | #12 | ||
Wizard
Posts: 1,163
Karma: 4917718
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Quote:
Quote:
Thanks!! |
||
11-23-2022, 06:47 AM | #13 | |
the rook, bossing Never.
Posts: 11,589
Karma: 87456643
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Caption problem | elbona88 | Conversion | 2 | 05-02-2018 02:24 PM |
keeping image and caption together | whbenson | ePub | 0 | 08-20-2013 06:19 PM |
Keeping caption and illustration together | John123 | ePub | 4 | 12-02-2012 09:19 AM |
Caption, distance from image | GraciousMe | Sigil | 10 | 10-30-2012 11:12 AM |
Center Image and Caption | SamL | ePub | 11 | 08-12-2011 09:27 AM |