asp.net - HTML 属性 bgcolor 已弃用 : What To Use Instead?

标签 asp.net html

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">

您可以在 CSS 中放置任何您喜欢的内容,有关 CSS 的更多信息 here , 和 here .

关于asp.net - HTML 属性 bgcolor 已弃用 : What To Use Instead?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/361633/

相关文章:

javascript - 从asp.net中的可编辑div中获取内部html

asp.net - 角色/声明访问控制系统的替代方案

html - 如何使用 css 和 html 将输入类型 ="text"放在图像上

.net - 如何避免 ASP.NET 应用程序中的 SQL 注入(inject)攻击?

c# - asp.net 工具提示对于里面的文本来说显得很大

asp.net - 如何在 ASP.NET MVC 2 应用程序中显示授权错误消息?

javascript - 如何在html或javascript中默认按下按钮

jquery - jquery中动态打印ul id名称

html - 如何在 Vuetify.js 中使文本换行到下一行

html - CSS:使悬停动画流畅