html table 灰色,HTML Table Color

HTML Table Color

This page contains HTML table color code. In other words, HTML codes for specifying or changing the color of your tables within your web page.

HTML table color is specified using Cascading Style Sheets (CSS).

Change Table Background Color

To change the background color of a table, use the CSS background-color property.

The following example sets the background color for the whole table. You can also set the background color of a table row and an individual table cell.

Run

Stack editor

Unstack editor

Example

.myTable1 {

width:100%;

text-align: left;

background-color: gold;

}

HeaderHeader
Table cellTable cell
Table cellTable cell
Table cellTable cell

Change Color of Text in Table

To change the color of the text inside the table, you need to use the CSS color property. As with the background-color property, you can apply this against the whole table, a single row, or a single cell.

Run

Stack editor

Unstack editor

Example

.myTable2 {

width:100%;

text-align: left;

background-color: olive;

color: white;

}

HeaderHeader
Table cellTable cell
Table cellTable cell
Table cellTable cell

Table Border Color

To change the color of the border, you need to use one of the CSS border properties. In most cases, the best one to use is the border property. You need to provide this property with 3 values: a value for the width of the border, a value for the style of border (solid, dotted, etc), and another for the color of the border.

You'll notice that the following example only has a border around the outside of the table. This is working correctly - you can apply the border property against the whole table, or against single cells.

There are a few considerations to take into account when doing this. See HTML table borders for a more detailed explanation of table borders.

Run

Stack editor

Unstack editor

Example

.myTable3 {

width:100%;

text-align: left;

background-color: gold;

border: 10px solid yellowgreen;

border-radius: 5px;

}

HeaderHeader
Table cellTable cell
Table cellTable cell
Table cellTable cell

About HTML Colors

The examples on this page use basic color names to define the color to be used. HTML/CSS provides several different means of defining color. Here are some useful links to help you pick a color for your table:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值