2

Can anyone tell me how to create tables with alternating row colors in an epub? For example, I might want the default background color to be white, but every other row would have a light blue background.

Is there a good way to do that using a basic epub software program like Sigil, or by hand coding the HTML?

2 Answers 2

4

You can use the following CSS rules to style respectively even or odd table rows (See the Example on W3schools):

tr:nth-child(even) {
    background-color: #f2f2f2
}

tr:nth-child(odd) {
    background-color: #f2f2f2
}
1

In HTML just set the fill colours on each row to alternating values some authoring software probably has a table style that does this for you but off the top of my head I can't say which. MS-Word used to author HTML can do this but will probably do it the most verbose way possible, i.e. by having it set on every cell.

You could also do it with 2 styles applied to alternating rows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.