是否可以在不使用 !important
的情况下将字体设置为 normal
?
<table id="tasks">
<tr><td>Name</td><td>SomeTask</td></tr>
<tr><td>Time</td><td class="gray">08/11/2011</td></tr>
</table>
table#tasks td:first-child+td {
font-weight:bold;
}
.gray {
color: gray;
font-weight: normal !important;
}
table#tasks
中指定table
,因为页面上应该只有一个 ID 为tasks
的元素。我相信这甚至可能会带来性能上的好处。 - derekerdmann#tasks td:first-child+td.gray
吗?在 CSS 中,是否有任何情况可以使用类似于element#id
的选择器?我忘记了在哪里和为什么我使用了table#tasks
。 - johnny<th>
标签。即使它们在左侧而不是顶部,您行中的第一个单元格在语义上也符合标题单元格的条件,因此使用<th>
是适当的。根据您的目标,然后可以使用td
作为选择器来使文本加粗,而.gray
则能像您最初预期的那样工作。 - Shaunath
吗?就像这样 http://jsfiddle.net/DvBes/11/? - johnnyth
的作用。请查看 WhatWG 文档中 4.9.2 节后面的示例 - http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#the-table-element 注意加粗的数字,两组都使用了th
。 - Shauna