How to style each table cell in a column via CSS?

前端 未结 6 977
慢半拍i
慢半拍i 2020-12-13 08:22

I have an ordinary HTML table:

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 09:04

    Well for the first and last columns you can use the :first-child and :last-child pseudo class:

    /* make the first cell of every row bold */
    tr td:FIRST-CHILD{
        font-weight:bold;
    }
    
    /* make the last cell of every row italic */
    tr td:LAST-CHILD{
        font-style:italic;
    }
    

    Reference:

    • :first-child and :last-child

提交回复
热议问题
FAT ...