The row is one of the two basic parts of a table, which is, on the one hand, the main structural elements of HTML based web pages, and, on the other, the main building unit of databases. Together with the columns, they allow for the contents of a table to be organized in an easy to understand and use way.
Rows in HTML tables
In the context of HTML pages, the row represents the horizontal line of cells holding the information input in a table. Each cell within a row may contain various type of information like text, paragraphs, images, lists, links, forms, etc. So, this means that you can place different page contents elements within a single table row.
Within the HTML code the table row is marked with a <tr> tag where tr stands for a 'Table Row'. To set apart a group of table cells in a row you need to just begin it with <tr>, no end tag </tr> is necessary. The table cells, containing the actual data of the table, are marked with the <td> tag. The example below demonstrates how the block of code for a 3-row table should look like.
Example of a table containing three rows, each begun by the <tr> tag:
<table border="1"summary="This table charts the number of
cups of coffee consumed by each senator,
the type of coffee (decaf or regular),
and whether taken with sugar.">
<CAPTION>Cups of coffee consumed by each senator</CAPTION>
<tr>
<th id="header1">Name</th>
<th id="header2">Cups</th>
<th id="header3" abbr="Type">Type of Coffee</th>
<th id="header4">Sugar?</th>
<tr>
<td headers="header1">M. Drun</td>
<td headers="header2">10</td>
<td headers="header3">Espresso</td>
<td headers="header4">No</td>
<tr>
<td headers="header1">K. Jazzy</td>
<td headers="header2">5</td>
<td headers="header3">Decaf</td>
<td headers="header4">Yes</td>
<tr>
<td headers="header1">V. Floppy</td>
<td headers="header2">6</td>
<td headers="header3">Ness</td>
<td headers="header4">Yes</td>
</table>
Example of how the same 3-row table will appear in a browser:
Name | Cups | Type of Coffee | Sugar? |
---|---|---|---|
M. Drun | 10 | Espresso | No |
K. Jazzy | 5 | Decaf | Yes |
V. Floppy | 6 | Ness | Yes |
<tr> attributes
The table rows may define certain style properties for the contained data cells. This is done with the help of special style attributes to the <tr> tag:
align attributeDefines the horizontal alignment of cells within a row. There are a few possible alignment positions defined by this attribute - left (the cell contents are aligned to the left side of the cell), center (the cell data is positioned at the center of the cell), right (the data is aligned to the cell's right side), justify (the data contents are aligned bilaterally), char (the cell contents are aligned to the character defined by the CHAR attribute).
valign attributeA style attribute defining the vertical alignment of cells within a row. Using this attribute you can define several different positions for the contents of row cells - top (the cell data are placed at the top of the cell), middle (the cell contents are centered vertically), bottom (the date is located at the cell's bottom) and baseline (the first line of all cells in a column are equally aligned).
bgcolor attributeA style attribute specifying the background color of row cells. This attribute is considered deprecated due to its inflexibilities and incompatibity with some browsers. For that reason, you will be recommended to use stylesheets for specifying a row's background color instead of this row attribute.
Rows in databases
Since tables have another important application - to store and organize the information in databases, we can talk about database table rows as well. In the context of databases, a row represents a single line of data cells in a table, while columns refer to the vertical lines of data cells in the same table.
All rows within a table are characterized by the one and the same structure and you can have as many of them as you need. Each row by rule contains related content i.e. the cells in a row represent information related to one and the same object, where each cell contains a data value of a particular type as defined by the table column. For example, let's say a table keeps record of the online payments made by customers on an e-store. Each customer will have one row assigned in this table, where the first data cell will spedify a unique identifier (that identfies the customer on record), the second will include the name of the buyer, the third - the amount of money paid by him for the service, the fourth - the payment currency, etc.