91-9990449935 0120-4256464 |
HTML TableHTML table tag is used to display data in tabular form (row * column). There can be many columns in a row. HTML tables are used to manage the layout of the page e.g. header section, navigation bar, body content, footer section etc. But it is recommended to use div tag over table to manage the layout of the page . HTML Table Tags
HTML Table ExampleLet's see the example of HTML table tag. It output is shown above. Test it NowOutput:
In the above html table, there are 5 rows and 3 columns = 5 * 3 = 15 values. HTML Table with BorderThere are two ways to specify border for HTML tables.
1) HTML Border attributeYou can use border attribute of table tag in HTML to specify border. But it is not recommended now. Test it NowOutput:
2) CSS Border propertyIt is now recommended to use border property of CSS to specify border in table. Test it NowYou can collapse all the borders in one border by border-collapse property. Test it NowOutput:
HTML Table with cell paddingYou can specify padding for table header and table data by two ways:
The cellpadding attribute of HTML table tag is obselete now. It is recommended to use CSS. So let's see the code of CSS. Test it NowOutput:
HTML Table with colspanIf you want to make a cell span more than one column, you can use the colspan attribute. Let's see the example that span two columns. CSS code: HTML code: Test it NowOutput:
HTML Table with rowspanIf you want to make a cell span more than one row, you can use the rowspan attribute. Let's see the example that span two rows. CSS code: HTML code: Test it NowOutput:
HTML table with captionHTML caption is diplayed above the table. It must be used after table tag only. Test it NowStyling HTML table even and odd cellsCSS code: Test it NowOutput: Supporting Browsers
Next TopicHTML Lists
|