View Full Version : Tables in ePub: CSS


virtual_ink
02-16-2012, 12:26 AM
I'm exploring the possibilities of formatting tables with CSS/XHTML. I'm sure there will be a few questions as I go, but right now I'm wondering:

Can you control the length of a particular column? I'd like 'column one' to be 75%, and 'column two' to be 25% of the page width.

virtual_ink
02-16-2012, 12:55 AM
Second question: Is it possible to ensure table stays on one page? They look terrible when split over two pages.

Toxaris
02-16-2012, 03:52 AM
It is quite easy to fix the width of a column to a fixed percentage. If it only two columns, you only need to specify one.

.colw {
width: 75%;
}

and in HTML:

<table width=100%>
<tr>
<td class="colw">75%</td>
<td>the rest...</td>
</tr>
</table>


Keeping the table on one page is difficult. You could try something with page-break-avoid, but than it must fit on a page. With the different zoomlevels, that is hard to control.

virtual_ink
02-16-2012, 09:13 PM
Thanks for the helpful tips Toxaris. Good point re zoomlevels vs pagebreaks.

KLUTCH
02-23-2012, 12:07 PM
I would recommend dropping the font size to keep it on one page, looks much better on the kindle :)

Toxaris
02-23-2012, 03:51 PM
I would recommend dropping the font size to keep it on one page, looks much better on the kindle :)

Since Kindle does not support ePUB, that is not a real issue.

Anyway, fontsize is a little tricky. There are different sizes of readers with different resolutions, so which fontsize to choose?
Also, some people want to enlarge the font so they are able to read it. That will definitely break your page. I really dislike fixed fontsizes.