[CSS]テーブル(table、td)の背景色を指定するサンプル

2021年10月4日

書式
table {background :xxx}
td {background:xxx}
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<style>
table {
border-collapse: separate;
border-spacing: 1px;
width: 100px;
/*背景色としてtableにyellowを指定*/
background: yellow
}
td {
/*背景色としてtdにskyblueを指定*/
background: skyblue
}
</style>
<table>
<tr>
<td>AA</td>
<td>11</td>
</tr>
<tr>
<td>BB</td>
<td>22</td>
</tr>
</table>
<style> table { border-collapse: separate; border-spacing: 1px; width: 100px; /*背景色としてtableにyellowを指定*/ background: yellow } td { /*背景色としてtdにskyblueを指定*/ background: skyblue } </style> <table> <tr> <td>AA</td> <td>11</td> </tr> <tr> <td>BB</td> <td>22</td> </tr> </table>
<style>
table {
    border-collapse: separate;
    border-spacing: 1px;
    width: 100px;
    /*背景色としてtableにyellowを指定*/
    background: yellow
  }
  td {
    /*背景色としてtdにskyblueを指定*/
    background: skyblue
  }
</style>

<table>
  <tr>
    <td>AA</td>
    <td>11</td>
  </tr>
  <tr>
    <td>BB</td>
    <td>22</td>
  </tr>
</table>

 

CSS

Posted by arkgame