This article is currently in the process of being translated into Hungarian (~14% done).


Colspan & Rowspan

The way the HTML markup is structured means that you in some rows can have four cells, some three cells, some two cells and so forth. In order for this to actually function, you need to use the attributes colspan and rowspan (the value of these attributes is always whole numbers). It can be quite tricky to use these attributes so you might need some patience.

Használjuk a példát az előző fejezetből és legyen meg az első sornak három helyett kettő cella legyen és emellett egyesítsük a 3. és 4. oszlopot a második cellánál.

<table border="1" width="100%">
		<td colspan="2">Row 1, cell 1</td>
		<td>Row 1, cell 2</td>
		<td>Row 2, cell 1</td>
		<td>Row 2, cell 2</td>
		<td>Row 2, cell 3</td>
		<td>Row 3, cell 1</td>
		<td rowspan="2">Row 3, cell 2</td>
		<td>Row 3, cell 3</td>
		<td>Row 4, cell 1</td>
		<td>Row 4, cell 3</td>

As you can see, I removed the third cell in row 1 and added the colspan attribute to the first cell in row 1. What you need to know when you want to create cells that spans across columns is, that the span is always to the right.

To create a cell that spans across rows, you have to remember to that when you span across rows, the span is always downwards. This means, you have to remove a cell in the following rows or else the table is not going to look like you intended.

This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!