要设置表格内容与边框之间的距离应该使用什么属性

要设置表格内容与边框之间的距离应该使用什么属性,第1张

要设置表格内容与边框之间的距离应该使用什么属性,要设置表格内容与边框之间的距离应该使用cellpadding属性,间的空白部分(以像素为单位)。 cellpadding是指单元格边距,也就是设置单元格内容与单元格边框的距离的属性。

用 css 的 border 解决

table {

border-collapse: collapse //切记是 <table>的属性,而非 <td>的.

}

border-collapse中的 collapse 和 separate 值,定义为collapse时,边框会重叠在一起。定义为separate时单元格边框之间会有间隙。不定义时默认为separate。

cus:cellpadding,cellspacing都是废弃的属性了,早已不推荐使用,最新的html5里已经彻底去掉了这些表现型的属性。

扩展资料

html5中不再支持table的cellspacing和cellpadding属性

如果现在开始用html5的声明来写页面时,会发现在定义table的cellspacing和cellpadding时被提示该属性已过时或者提示非法属性。具体原因是在html5中table标签的这两个属性已经被移除,需要定义边框之类的时应该使用css的写法。

具体实现如下:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

  <title>Html5 Table Test</title>

  <style type="text/css">

      table{ border-collapse:collapseborder:solid 1px Black}

      table td{ width:50pxheight:20px  border:solid 1px Blackpadding:5px}

  </style>

</head>

<body>

  <table>

      <tr>

          <td></td>

          <td></td>

      </tr>

      <tr>

          <td></td>

          <td></td>

      </tr>

  </table>

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/tougao/11274326.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-14
下一篇2023-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存