Write the HTML CODE for the given table using colspan and
rowspan. [ 5 marks]
SUBJECT MAXIMIUM
MARKS
MARKS OBTAINED
BIOLOGY PRACTICAL 30 20
THEORY 70 40
CHEMISTRY PRACTICAL 30 15
THEORY 70 50
PHYSICS PRACTICAL 30 18
THEORY 70 30
Answers
Display
inline
Attribute of
<th> — table header — A header cell in a <table>.
<td> — table data — A data cell in a <table>.
What does colspan= do?
Allows a single table cell to span the width of more than one cell or column.
What does rowspan= do?
Allows a single table cell to span the height of more than one cell or row.
Why use colspan= or rowspan=?
Sometimes it makes sense for a cell to span multiple columns or multiple rows. This might be used for a header cell that titles a group of columns, or a side-bar that groups rows of entries.
Both colspan= and rowspan= are attributes of the two table-cell elements, <th> and <td>. They provide the same functionality as “merge cell” in spreadsheet programs like Excel.
The value of either attribute must be a positive integer (a whole number). The value specifies the number of columns or rows that the cell fills.