Tables in HTML

Tables :


                  In general table define that combination of rows and columns. In HTML also we have table with rows and columns using tags. Table is defined with <table>. In table three important tags are used to display content in the web page.


  1. <th>  - table headings defines head of each column. (By default it will display with bold text and center aligned format)
  2. <tr>   - table row defines each row in the table
  3. <td>  - table data defines the data containers of the table which contains text,images,etc.


Table Attributes:


  1. align - used to align a whole table with it values like left (default value), center and right. 
  2. background - used to apply images as background to a table.
  3. bgcolor - only colors as background to a table.
  4. width and height - used to mention width and height of a table without any units.
  5. border - apply border to whole table and also for table cells.
  6. bordercolor - used to give colors to the border of table and its cells.
  7. cellpadding - defines the space between the text and border of a cell in table.
  8. cellspacing - defines the space between two cells in a table.
  9. rules - used to display lines as border for both table and its cells. It has four values - 
    1. all - in both row wise and column wise.
    2. rows - only row wise.
    3. cols - only column wise.
    4. none - only for the table not for the cells.

TH,TR,TD - attributes :-

           Some common attributes are there in both table and th,tr,td tags. Few different attributes are available as follows:


  1. align - here it is used to align the content in horizontal order. values like - left, center, right
  2. valign - used to align the content in vertical order. values like - top, middle, bottom.
  3. rowspan - used to merge two or more cells in row wise.
  4. colspan - used to merge two or more cells in column wise.

Example:



Output:-





No comments:
Write comments