【问题标题】:How to replace table attributes?如何替换表属性?
【发布时间】:2013-07-18 08:43:29
【问题描述】:

我有以下 HTML:

<table cellspacing="0" cellpadding="0" width="100%">

所以我验证了我的 HTML 文档,我发现这些已经过时了。但是,如果我删除它们,我的网站对齐将无法按我的意愿工作。我需要一种足够好的方法来用 CSS 代码替换属性。

【问题讨论】:

  • 为什么不给表格本身增加宽度?例如,&lt;table cellspacing="0" cellpadding="0" width="100%"&gt;?
  • @NathanLee ,他希望将其从表格标记中删除?

标签: html css w3c-validation


【解决方案1】:
    <style type="text/css">
        .table1_style
        {
            border-collapse: collapse;
            border-spacing: 0px;
        }
        .table2_style
        {
            width: 100%;
        }
    </style>

<table class="table1_style">
<tr>
<td>
</td>
</tr>
</table>
<table class="table2_style">
<tr>
<td>
</td>
</tr>
</table>

【讨论】:

    【解决方案2】:

    你必须用css写这些东西:

    border-collapse: collapse;
    border-spacing: 0px;
    width: 100%;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-25
      • 2016-04-21
      • 2016-12-06
      • 2014-04-24
      • 1970-01-01
      • 1970-01-01
      • 2020-11-20
      • 2018-05-06
      相关资源
      最近更新 更多