Usage of table in html

下次还敢
Release: 2024-04-27 20:54:38
Original
504 people have browsed it

HTML table is a tool for organizing data into a grid-like structure, consisting of rows and columns. To create a table, you need to use the <table> tag, where <thead> and <tbody> represent the table header and table body respectively, <tr> represents the row, <th> and <td> represent the table header and table body respectively. body cell. Tables can set borders, spacing and width.

Usage of table in html

Using HTML tables

What is an HTML table?

HTML tables are used to organize data into a grid-like structure, and each cell is called a cell. Tables are made up of rows and columns, with rows being horizontal and columns being vertical.

How to create an HTML table

To create a table in HTML, you need to use the <table> tag:

<code class="html"><table>
  <thead>
    <tr><th>列标题 1</th><th>列标题 2</th></tr>
  </thead>
  <tbody>
    <tr><td>单元格 1</td><td>单元格 2</td></tr>
    <tr><td>单元格 3</td><td>单元格 4</td></tr>
  </tbody>
</table></code>
Copy after login
  • <thead> and <tbody> represent the table header and table body respectively.
  • <tr> represents row.
  • <th> represents the header cell.
  • <td> represents the table body cell.

Table properties

  • border: Control the thickness of the table border.
  • cellspacing: Set the vertical spacing between cells.
  • cellpadding: Set the spacing between elements in the cell and the cell border.
  • width: Specifies the width of the table.

Header and table body

  • Header (<thead>): Contains the title or column in the table Label.
  • Table body (<tbody>): Contains the actual data in the table.

Cell Properties

  • colspan: Specifies the number of columns that the cell spans.
  • rowspan: Specifies the number of rows that the cell spans.
  • align: Specifies the alignment of text within the cell.

Example

The following is a simple table with borders and padding:

<code class="html"><table border="1" cellpadding="5">
  <tr><th>姓名</th><th>年龄</th></tr>
  <tr><td>张三</td><td>20</td></tr>
  <tr><td>李四</td><td>25</td></tr>
</table></code>
Copy after login

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

Related labels:
lsp
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!