![]() |
#1 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 36
Karma: 82258
Join Date: May 2021
Device: kindle
|
Formatting tables best practices
I have had varying degrees of success formatting tables for eBooks. Here is an example of one I did recently that seems to work OK.
Code:
table { max-width: 90%; border-collapse: collapse; border-spacing: 0; margin: 1em auto 0 auto; vertical-align: baseline; } #table td, th { border: 1px solid #ddd; padding: 5px; } Code:
<table summary="" id="table"> <tbody> <tr> <td> *** </td> <td> *** </td> <td> *** </td> </tr> <tr> <td> *** </td> <td> *** </td> <td> *** </td> </tr> <tr> <td> *** </td> <td> *** </td> <td> *** </td> </tr> <tr> <td> *** </td> <td> *** </td> <td> *** </td> </tr> </tbody> |
![]() |
![]() |
![]() |
#2 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,292
Karma: 20171067
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
|
That's almost exactly what I use. Although, I tighten up the css a little, but that is just technique, not at all required.
Code:
table { max-width: 95%; border-collapse: collapse; margin: 1em auto; } tbody td { border: 1px solid black; padding: 5px; text-align:center } tbody td:first-child { text-align: right } I have seen css using "id" tags to define something specific...especially if it is used with js, but I haven't figured out if there is a point to it just to say that it is a tag... (especially since the IDs need to be unique). eg. <table id="table"> ...same concept as people using classes (<p class="para">, <blockquote class="block">, etc.). Just define the base tag, then use a class or ID for a specific deviation from the default. If there IS a reason, I would be interested in knowing. You will also hear that tables should only be used when you absolutely MUST... and anything larger than 2-3 columns should be re-thought as it really messes up the display on smaller screen sizes; large tables usually do better as an image. |
![]() |
![]() |
![]() |
#3 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 36
Karma: 82258
Join Date: May 2021
Device: kindle
|
Quote:
Yes I have already made some tables in to images before that definitely would not be possible in an eBook. I also try to avoid them where possible. |
|
![]() |
![]() |
![]() |
#4 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
Code:
<table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Tex</td> <td>999</td> </tr> <tr> <td>Example</td> <td>123</td> </tr> </table> Using HTML allows font + size + color to be changed, read by Text-to-Speech, etc. etc. (Everything that makes ebooks great.) For more details, see my posts:
If you want to go further, you can introduce a <thead> along with your <tbody> + add scope= to your rows/column headings: Code:
<table> <thead> <tr> <th scope="col">Name</th> <th scope="col">Age</th> </tr> </thead> <tbody> <tr> <td>Tex</td> <td>999</td> </tr> <tr> <td>Example</td> <td>123</td> </tr> </tbody> </table> See: And if you want your tables properly designed (so many tables are AWFUL)... This GIF sums it up nicely: "How to make your tables less terrible" Pretty much:
If you want more technical details on that, I highly recommend the absolutely fantastic book: "The Visual Display of Quantitative Information" by Edward Tufte. Last edited by Tex2002ans; 06-20-2021 at 04:04 PM. |
|
![]() |
![]() |
![]() |
#5 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,581
Karma: 14328510
Join Date: Nov 2019
Device: none
|
Also similar to mine. But I think that the nth-child and first-child stuff doesn't work on the kobo, but I can't remember for sure. currentColor should be safer than black or some hex value; it does the right thing when the user switches to dark/night mode (white text on a black background); this is true everywhere you want black, not just tables.
Code:
table { margin-left: auto; margin-right: auto; border-collapse: collapse; margin-top: 1em; } table caption { font-weight: bold; padding-bottom: 0.5em; } table.coltwonum td:nth-child(2) { text-align: right; } table.colsthreenum td:nth-child(3) { text-align: right; } table.colfournum td:nth-child(4) { text-align: right; } table.colfivenum td:nth-child(5) { text-align: right; } td { border: 1px solid currentColor; empty-cells: show; padding: 0.125em; text-align: left; } tr.final { border-top: 2px solid currentColor; } |
![]() |
![]() |
![]() |
#6 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
I see you used caption in your CSS. How have you found support for that across devices?
I still include my captions in a separate <div>/<p>: Code:
</table> <div class="caption"> <p class="caption">Figure 1.1. This is an example.</p> </div> Code:
div.caption { margin-bottom: 1em; } p.caption { text-align: center; text-indent: 0; } Last edited by Tex2002ans; 06-20-2021 at 08:58 PM. |
![]() |
![]() |
![]() |
#7 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 312
Karma: 3196258
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
|
|
![]() |
![]() |
![]() |
#8 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,581
Karma: 14328510
Join Date: Nov 2019
Device: none
|
|
![]() |
![]() |
![]() |
#9 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
"Why Road Barriers Stopped Killing Drivers" And about halfway through the video, they flash a few tables showing off death/safety statistics: Bleh!!! Ptoowey! 1. You see all that centered alignment? It makes it impossible to skim your eyes down a column and COMPARE rows. (The entire purpose of using a table in the first place.) If you right-align numbers, all:
2. All those $ signs in every row? Get rid of those and move those into the column header. 3. You see all those vertical lines? You think you need them, but they're useless. 4. You see all those horizontal lines between rows? You think you need them, but they're useless. Optional exceptions: 1 above/below the table + 1 between the header/data. (This visually separates the table from the text itself.) * * * Here's 3 versions of the same table in various stages of cleanup (from worse->better): Spoiler:
And here's what an HTML recreation might look like: Same exact data. Perfectly readable, perfectly understandable. Tools you need? Alignment + spacing. Bold is optional (although not even needed). Quote:
https://developer.mozilla.org/en-US/...S/caption-side so I gave up and didn't look much further. (I remember it working on a few of the devices, but failing on many others.) It may be okay for very simple tables... but the kinds of complicated tables I work on, I just wrote off the entire thing. ![]() But I'd definitely be open for anyone else's testing/research on it. In all these years on MobileRead, I can't recall anyone ever really speaking about <caption>. Last edited by Tex2002ans; 06-21-2021 at 02:57 PM. |
||
![]() |
![]() |
![]() |
#10 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,292
Karma: 20171067
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
|
I totally agree with Tex...especially for a full html website. But, for an ePub, I still don't like the look of large tables (more than 2-3 columns) on small screens (think phones in portrait mode). You just get too squished, or columns run off the page, or font has to be too small to fit everything...
|
![]() |
![]() |
![]() |
#11 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
![]() The HTML advantages of Accessibility + TTS + searchability + copy/pastability + following user settings... outweigh the pros of static images. (Wow, "it looks the same" as the print book + I can use the background as a flashlight! ![]() Quote:
Like Kindle now allows you to expand/scroll large tables (similar to zooming + panning/scanning large resolution images). I believe Kobo has similar functionality too. You also have rotatable devices, so some can be flipped to landscape temporarily if you stumble across a wide table. * * * And on wide tables... Transposing/Verticalization, where you flip the X- + Y-axis, can also be used. For example: 6x3 Code:
Name Color Cool? Number Tabs # Teas Tex Red Very 1 15 30 Turtle Gray Meh 2 99 5 Code:
Name Tex Turtle Color Red Gray Cool? Very Meh Number 1 2 Tabs 15 99 # Teas 30 5 Me and Hitch also discussed that (I believe in those same linked threads). Print books are also limited by vertical size of the page, hence more horizontal tables. Ebooks have infinite verticality, but limited horizontal space (skinny cellphones + large fonts), hence vertical tables may be better. Last edited by Tex2002ans; 06-21-2021 at 08:47 PM. |
||
![]() |
![]() |
![]() |
#12 | ||
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,292
Karma: 20171067
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
|
Quote:
Is that tech just on new devices or is it supported on the older hardware? Quote:
![]() I usually use auto-scroll on my reader, Marvin, so I truly have unlimited vertical space. However, if you have 'paged' content, does the ePub spec support the "display: table-header-group" property to repeat the header across breaking pages?? |
||
![]() |
![]() |
![]() |
#13 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
I assume it's a KFX thing. Maybe jhowell or someone who has a Kindle can give more information. Quote:
But when I use <thead> it duplicates headings to the next page in Gitden Reader (Android) + PocketBook Reader (Android) + even in an EPUB->DOCX conversion using EPUBTools. I haven't done extensive testing though. And at the worst case, it'll just split tables/cells as normal. Last edited by Tex2002ans; 06-22-2021 at 04:39 PM. |
||
![]() |
![]() |
![]() |
#14 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,000
Karma: 89771343
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
Quote:
When enabled the table is followed by an icon of a box with a diagonal two headed arrow indicating that the table can be expanded. Clicking that opens a screen containing just the table that can be panned and zoomed like an image to view it in more detail. |
|
![]() |
![]() |
![]() |
#15 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Thanks for the detailed info.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[KOBO] Strip existing formatting to apply my own default formatting to all books | digital_steve | Calibre | 2 | 08-10-2010 06:34 PM |
Calibre and FORMATTING how to stop it altering my formatting? | nerys | Calibre | 37 | 07-23-2010 02:35 AM |
Calibre and FORMATTING how to stop it altering my formatting? | nerys | Calibre | 0 | 02-28-2010 04:51 PM |
line formatting formatting question | daesdaemar | Workshop | 9 | 02-06-2009 11:47 AM |