生成一个四行四列的表格
时间: 2024-02-29 13:56:35 浏览: 14
| 列1 | 列2 | 列3 | 列4 |
| --- | --- | --- | --- |
| 行1列1 | 行1列2 | 行1列3 | 行1列4 |
| 行2列1 | 行2列2 | 行2列3 | 行2列4 |
| 行3列1 | 行3列2 | 行3列3 | 行3列4 |
| 行4列1 | 行4列2 | 行4列3 | 行4列4 |
相关问题
前端生成一个九行四列的表格
可以使用HTML和CSS来生成一个九行四列的表格,具体的做法如下:
```html
<!DOCTYPE html>
<html>
<head>
<title>九行四列的表格</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: center;
}
th {
background-color: lightgray;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>标题1</th>
<th>标题2</th>
<th>标题3</th>
<th>标题4</th>
</tr>
</thead>
<tbody>
<tr>
<td>内容1-1</td>
<td>内容1-2</td>
<td>内容1-3</td>
<td>内容1-4</td>
</tr>
<tr>
<td>内容2-1</td>
<td>内容2-2</td>
<td>内容2-3</td>
<td>内容2-4</td>
</tr>
<tr>
<td>内容3-1</td>
<td>内容3-2</td>
<td>内容3-3</td>
<td>内容3-4</td>
</tr>
<tr>
<td>内容4-1</td>
<td>内容4-2</td>
<td>内容4-3</td>
<td>内容4-4</td>
</tr>
<tr>
<td>内容5-1</td>
<td>内容5-2</td>
<td>内容5-3</td>
<td>内容5-4</td>
</tr>
<tr>
<td>内容6-1</td>
<td>内容6-2</td>
<td>内容6-3</td>
<td>内容6-4</td>
</tr>
<tr>
<td>内容7-1</td>
<td>内容7-2</td>
<td>内容7-3</td>
<td>内容7-4</td>
</tr>
<tr>
<td>内容8-1</td>
<td>内容8-2</td>
<td>内容8-3</td>
<td>内容8-4</td>
</tr>
<tr>
<td>内容9-1</td>
<td>内容9-2</td>
<td>内容9-3</td>
<td>内容9-4</td>
</tr>
</tbody>
</table>
</body>
</html>
```
在上述代码中,首先使用`<table>`标签创建一个表格,然后使用`<thead>`标签创建表头,其中包含四个`<th>`标签,分别用于显示四个列的标题。接着使用`<tbody>`标签创建表格的主体,其中包含了九个`<tr>`标签,分别表示每一行的内容,其中每行包含了四个`<td>`标签,分别用于显示每个单元格的内容。最后使用CSS对表格进行样式设置,设置了表格的边框、内边距、文本居中以及表头背景色等属性。
生成一个三行五列的html表格
要生成一个三行五列的HTML表格,可以使用以下代码:
```
<table>
<tr>
<td>行1列1</td>
<td>行1列2</td>
<td>行1列3</td>
<td>行1列4</td>
<td>行1列5</td>
</tr>
<tr>
<td>行2列1</td>
<td>行2列2</td>
<td>行2列3</td>
<td>行2列4</td>
<td>行2列5</td>
</tr>
<tr>
<td>行3列1</td>
<td>行3列2</td>
<td>行3列3</td>
<td>行3列4</td>
<td>行3列5</td>
</tr>
</table>
```
这段代码中,`<table>`标签定义了一个表格,`<tr>`标签定义了表格中的一行,`<td>`标签定义了表格中的一个单元格。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)