使用 HTML 中的 border 属性来显示边框的粗细。
注意 − HTML5 不支持此属性。
示例
您可以尝试运行以下代码来了解如何在 HTML 中实现 border 属性 −
<!DOCTYPE html>
<html>
<body>
<h2>Cricketers</h2>
<table style="width:100%" border="1">
<th>Name</th>
<tr>
<td>Sachin Tendulkar</td>
</tr>
<tr>
<td>Virat Kohli</td>
</tr>
</table>
</body>
</html>
登录后复制
请使用 CSS,因为 HTML5 中已弃用 border 属性。
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<h2>Cricketers</h2>
<table style="width:100%">
<caption>Indian Cricketers</caption>
<th>Name</th>
<tr>
<td>Sachin Tendulkar</td>
</tr>
<tr>
<td>Virat Kohli</td>
</tr>
</table>
</body>
</html>
登录后复制
以上就是我们如何在HTML中显示元素的边框厚度?的详细内容,更多请关注www.92cms.cn其它相关文章!






