When creating websites, some data would not make sense unless it in table. Tables are just spreadsheets which contain rows and columns. Table in HTML is created by the use of the table tag . The table is written row by row which is done by the use of
tag which stands for table row. Each cell is written using the tag
. The cell is the column of the table. A typical table will be written in the following sequence.
row 1, column 1 | row 1, column 2 |
Row 1, Column 1 | Row 2 Column 2 |
and will produce a table that looks like
Row 1, Column 1 Row 1, Column 2
Row 2, Column 1 Row 2, Column 2
The table must have a heading. The tag
is replaced with the tag
which is the heading of the contents of the table. It is important for the table contents to be readable. The size of the rows and columns should be of standard size. The height of the width using the height and width attributes. Not too small or too big. However, the table can have large columns and rows when the content input extends beyond the size of the columns and rows designated. They are usually self adjustable depending on the amount of data input. For enhanced readability, cell spacing and cell padding are used to adjust the white space of the rows and columns. Cell spacing is the width of the border while cell padding is the distance between the content of the columns and rows and the borders.
At times, there is need to merge two columns or rows. Colspan and rowspan are used to attributes are used to merge two or more columns and two or more rows respectively. The two can be used with the tag
before the other tags of the table are set. Like all elements used on the internet, there has to be consistent contrast on the table. This is determined by the colour of the background and that of the text. When the background of the table is brightly coloured, the text should be darkly coloured and vice versa. By default, the background of the table is usually white and the text colour used is normally black.However, one can change the colours of the two according to his preference. Colours that are easily visible should be used to allow the user to Cleary see the contents of the table. The colour of the background is set using the attribute bgcolor. The border of the columns and rows can also be coloured. Always ensure that the colours used in the three elements contrast accordingly and they can be visualized with ease. You can also add images to the background using the bgcolor attribute. Depending on what you are targeting, you can use a table inside another table. This is enhanced by using the technique of nesting tables.