使用colspan更改文本颜色,怎么了?

时间:2019-01-25 14:11:25

标签: html css

我不能更改下表中文本的颜色(背景颜色可以毫无问题地更改)。文字对齐均无效,因为我注意到只有背景可以改变。 W3schools.com说: colgroup 标签对于将样式应用到整个列很有用,而不是为每一行的每一行重复样式。

我知道还有另一种解决方案,但是这段代码有什么问题

所以我的问题是:为什么我不能更改文本的颜色,是否有逻辑上的解释,或者是错误?

<html>
<body>
<table>
   <colgroup>
      <col style="color:red">
      <col style="background-color:yellow;text-align: center;">
      <col style="color:red">
   </colgroup>
   <tr>
      <td>this text should be red</td>
      <td>the background is yellow.</td>
      <td>this text should be red</td>
   </tr>
   <tr>
      <td>this text should be red</td>
      <td>Not centered!</td>
      <td>this text should be red</td>
   </tr>
</table>
</body>
</html>

不想要“将文本颜色应用于html列”的解决方案,我的问题是为什么此代码不起作用的确切解释...

0 个答案:

没有答案
相关问题