Which is the correct code to merge four columns in a table?
A
<td colspan="4">
B
<td column span =*4">
C
<colspan = '4">
D
<td span = "4">
Answers
Answer:
<td colspan = 4 >
is correct
Explanation:
because it is the correct syntax for this ok
The correct cⱺde to merge four columns in a table is <td colspan="4">
A) <td colspan="4">
Extra Information
<table>..</table> tag is used to create a table in HTML
The tags which are used between <table> tag to create a table are
<tr>..</tr>
We can make row of table with <tr> tag.
<th>..</th>
This tag is used to define header of table.
<td>..</td>
This tag is used to create cells of table.
rowspan attribute
It is an attribute of <td> tag and it allows us to merge rows.
colspan attribute
It is an attribute of <td> tag and it allows us to merge columns.
Example
<!DOCTYPE html>
<html>
<head>
<style>
tr {text-align:center;}
</style>
</head>
<body>
<table border="1px solid black" style="border-collapse:collapse;" width="25%">
<tr>
<td rowspan="3">Data</td>
<td colspan="3">Row</td>
</tr>
<tr>
<td rowspan="2">Column</td>
<td>Data 1</td>
<td>Data 2</td>
</tr>
<tr>
<td>ABC</td>
<td>PQR</td>
</tr>
</table>
</body>
</html>
The table generated from this HTML will have two rollspan and one colspan.
rowspan="3" => 3 defines the number of rows to merge.
colspan="3" => 3 defines the number of columns to merge.