Basic Table Question

I’m making a table where the top row reads “Red”, then “Blue” then “Green”. For the second row, I only have 2 table datas “Yellow” and “Orange”. I wanted yellow to span two rows but only one column, and Orange to span both two rows AND two columns. as you can see, someone helped me by suggesting adding a “width” attribute. All though this does work, I feel that there is a much simpler way. When I tried before using only colspan and rowspan like I thought, it didn’t work. Any input? Here’s my link: https://code.sololearn.com/W2vaSigHagk3/#html

<table border="2" width="200">
    	            <tr>
    	                <td>Red</td>
    	                <td>Blue</td>
    	                <td>Green</td>
    	            </tr>
    	            <tr>
    	                <td height="40">Yellow</td>
    	                <td colspan="2">Orange</td>
    	            </tr>

    	        </table>

If you want a cell to take up two rows or two columns, then you do want rowspan or colspan.


If you just want a row to be taller or a column wider, then you want to use width and height

1 Like