html怎么将表格边框隐藏

2021-12-11,

html表格边框隐藏的方法:1、使用style属性给table、th、td元素添加“border: none;”样式;2、使用style属性给table元素添加“border-color: transparent;”样式。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

我们有下面一个表格:

<table border="1">
	<tr>
		<th>姓名</th>
		<th>年龄</th>
	</tr>
	<tr>
		<td>Peter</td>
		<td>20</td>
	</tr>
	<tr>
		<td>Lois</td>
		<td>20</td>
	</tr>
</table>

怎么将这个表格的边框隐藏起来?下面介绍一下方法:

1、给table、th、td元素添加border: none;样式

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
	</head>

	<body>
<table border="1" style="border: none;">
	<tr>
		<th  style="border: none;">姓名</th>
		<th  style="border: none;">年龄</th>
	</tr>
	<tr>
		<td style="border: none;">Peter</td>
		<td style="border: none;">20</td>
	</tr>
	<tr>
		<td style="border: none;">Lois</td>
		<td style="border: none;">20</td>
	</tr>
</table>
	</body>
</html>

2、给table元素添加border-color: transparent;样式

<table border="1" style="border-color: transparent;">
	<tr>
		<th>姓名</th>
		<th>年龄</th>
	</tr>
	<tr>
		<td>Peter</td>
		<td>20</td>
	</tr>
	<tr>
		<td>Lois</td>
		<td>20</td>
	</tr>
</table>

推荐教程:《html视频教程》

以上就是html怎么将表格边框隐藏的详细内容,更多请关注北冥有鱼其它相关文章!

本文转载自【PHP中文网】,希望能给您带来帮助,苟日新、日日新、又日新,生命不息,学习不止。

《html怎么将表格边框隐藏.doc》

下载本文的Word格式文档,以方便收藏与打印。