<html>
<head>
<title>Tabelas no HTML</title>
<head>
<body>
<h1>Criação de Tabelas no HTML</h1>
<table>
<tr>
<th>Coluna 1</th>
<th>Coluna 2</th>
</tr>
<tr>
<td>Dado 1</td>
<td>Dado 2</td>
</tr>
</table>
</body>
</html>
Além dos elementos básicos também temos tags para criar tabelas mais elaboradas:
<html>
<head>
<title>Tabelas no HTML</title>
<head>
<body>
<h1>Criação de Tabelas no HTML</h1>
<table>
<tr>
<th>Coluna 1</th>
<th>Coluna 2</th>
</tr>
<tr>
<td>Dado 1</td>
<td>Dado 2</td>
</tr>
</table>
<hr>
<h2>Tabelas com cabeçalho</h2>
<table>
<thead>
<tr>
<th>Nome</th>
<th>Idade</th>
<th>Profissão</th>
</tr>
</thead>
<tbody>
<tr>
<td>João</td>
<td>30</td>
<td>Engenheiro</td>
</tr>
<tr>
<td>Maria</td>
<td>25</td>
<td>Advogada</td>
</tr>
</tbody>
</table>
</body>
</html>
Também é possível utilizar os atributos “colspan” e “rowspan” para manipular quantas células a tag irá ocupar:
<html>
<head>
<title>Tabelas no HTML</title>
<head>
<body>
<h1>Criação de Tabelas no HTML</h1>
<table>
<tr>
<th>Coluna 1</th>
<th>Coluna 2</th>
</tr>
<tr>
<td>Dado 1</td>
<td>Dado 2</td>
</tr>
</table>
<hr>
<h2>Tabelas com cabeçalho</h2>
<table>
<thead>
<tr>
<th>Nome</th>
<th>Idade</th>
<th>Profissão</th>
</tr>
</thead>
<tbody>
<tr>
<td>João</td>
<td>30</td>
<td>Engenheiro</td>
</tr>
<tr>
<td>Maria</td>
<td>25</td>
<td>Advogada</td>
</tr>
</tbody>
</table>
<hr>
<h2>Tabelas com células personalizadas</h2>
<table>
<thead>
<tr>
<th colspan="2">Informações Pessoais</th>
<th>Contato</th>
</tr>
</thead>
<tbody>
<tr>
<td>Nome:</td>
<td>João</td>
<td rowspan="2">Telefone: 123456</td>
</tr>
<tr>
<td>Idade:</td>
<td>30</td>
</tr>
</tbody>
</table>
</body>
</html>