Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

Table and Cell Color 261

10


This is how you change the background color of a table, a row, or a cell inside a row.
You use the background-color property or the background property. You can use the
style attribute in the and elements, just as you can in other elements.


Also, if you change the color of a cell, don’t forget to change the color of the text inside
it so that you can still read it.


Here’s an example of changing the background and cell colors in a table. I’ve created
a checkerboard using an HTML table. The table itself is white, with alternating cells in
black. The checkers (here, red and black circles) are images. In the source code, I’ve used
the background-color property on a class attribute to set background colors for some of
the cells :


Input ▼


<!DOCTYPE html>




Checkerboard