Home > Web Front-end > Front-end Q&A > How to hide table columns in html

How to hide table columns in html

WBOY
Release: 2021-12-17 15:53:43
Original
6239 people have browsed it

在html中,可以利用style属性给指定列的单元格元素添加“display:none”样式,实现隐藏table的列元素,语法为“...指定列单元格元素标签>”。

How to hide table columns in html

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

html怎样实现table列隐藏

在html中想要实现隐藏table元素的指定列元素,可以利用style属性。

通过style属性给指定列元素的单元格添加display:none的样式就能够隐藏这个单元格,进而隐藏整个列。

语法为:

<指定列单元格元素标签 style="display:none">...</指定列单元格元素标签>
Copy after login

示例如下:

<html>
<head> 
<meta charset="utf-8"> 
<title>123</title> 
</head>
<body>
<table border="1">
  <tr>
    <th>Month</th>
    <th style="display:none">Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td style="display:none">$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td style="display:none">$50</td>
  </tr>
</table>
</body>
</html>
Copy after login

输出结果:

How to hide table columns in html

推荐教程:《html视频教程

The above is the detailed content of How to hide table columns in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template