VStudio ASP.NET 给出以下消息:
Attribute 'bgcolor' is considered outdated. A newer construct is recommended.
推荐的结构是什么?
bgcolor
在 <td>
内元素。
另一条相关消息是:
Attribute 'bordercolor' is not a valid attribute of element 'table'.
有人知道我在哪里可以找到更新的替代品吗?
最佳答案
BGColor
在 W3C HTML 4.0 规范中已弃用。
较新的网站和网络应用程序使用 CSS(级联样式表)来呈现相同的内容,如下所示:
body {
background-color : #ffffff;
}
对于表格,执行以下操作:
<table>
<tr id="row1">
<th>Header 1</th> <td>Cell 1</td> <td>Cell 2</td>
</tr>
<tr id="row2">
<th>Header 2</th> <td>Cell 3</td> <td>Cell 4</td>
</tr>
<tr id="row3">
<th>Header 3</th> <td>Cell 5</td> <td>Cell 6</td>
</tr>
</table>
在你的 CSS 中:
th { text-align: center; font-weight: bold; vertical-align: baseline }
td { vertical-align: middle }
table { border-collapse: collapse; background-color: #ffffff }
tr#row1 { border-top: 3px solid blue }
tr#row2 { border-top: 1px solid black }
tr#row3 { border-top: 1px solid black }
这将使表格具有背景颜色,并对其余表格数据/表格行执行不同的操作。
简单地把它放在你的样式表中,然后像这样在你的网页上引用它:
<link rel="stylesheet" href="style.css" TYPE="text/css" media="screen">
关于asp.net - HTML 属性 bgcolor 已弃用 : What To Use Instead?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/361633/