change color of rows in a table in HTML and CSS

后端 未结 6 646
天命终不由人
天命终不由人 2021-01-19 22:25

Trying to learn HTML and CSS and I have a simple question.

How can I give each row a different color in a table? For example row 1 is red, row 2 is blue etc.

6条回答
  •  一向
    一向 (楼主)
    2021-01-19 22:49

    The below small piece of code should change the color table row.

     table, td, th {
        border: 1px solid red;
    }
    
    th {
        background-color: red;
        color: black;
    }
    

    Source: http://www.snoopcode.com/css/css-tables

提交回复
热议问题