Skip to main content

Posts

Attributes of Table Tag

Border: It is used to specify a border and its thickness for a table. Cellspacing: It is used to specify the distance between adjacent cells in a table. Cellpadding : it is used to specify the distance between a cell and cell contents in a table. Width : It is used to specify width of a table in pixels or as percentage to screen width. Align : It is used to specify the horizontal alignment of a table. Possible horizontal alignment values are "left", "right" or "center". Valign : It is used to set the vertical alignment of a table as "top", "bottom" or "middle". Bgcolor : It sets the background color of a table. You can specify color names or hex values for the color. Example of table with border=1, width=200 and align=center attributes HTML Coding: <table border="1" width="200" align="center"> <tr> <th>Book</th><th>Price($)</th> </tr> <

Difference between Cellspacing and Cellpadding

Cellspacing and Cellpadding are two important attributes of  <Table> tag. As you know <Table> tag is used to create and display tables in HTML documents. What is CELLSPACING? Cellspacing is an important attribute of <Table> tag in HTML. Cellspacing specifies the spacing between adjacent cells in a table. Consider the following example of an HTML table with cellspacing attribute set to 50. Example of Cellspacing use <TABLE border="1" cellspacing="30"> <th>Name</th><th>Marks</th> <tr><td>Sajid Mahmood</td><td>666</td> <tr><td>Majid Karim</td><td>555</td> </table> Name Marks Sajid Mahmood 666 Majid Karim 555 Example of Cellspacing=15 <TABLE border="1" cellspacing="15"> <th>Name</th><th>Marks</th> <tr><td>Sajid Mahmood</td><td>666</td> <tr><td>Majid K

Use Of Colspan and Rowspan in Tables HTML

Colspan and Rowspan are two important attributes of TD and TH tags used in HTML tables. Colspan Colspan is an attribute of TD or TH tags used to make data cells and header cells in an HTML table. We can use Colspan to expand / span a cell on many columns. For example, in the following table, the first header cell spans two columns, so here we use <th colspan="2">Marks</th> to get the required result in the displayed html table. Marks Maths Computer 100 87 The complete HTML coding is as follows: <table border="1"> <tr> <th colspan="2">Marks</th> </tr> <tr> <th>Maths</th><th>Computer</th></tr> <tr> <td>100</td><td>87</td> </tr> </table> Rowspan Rowspan attribute is used to expand or span a cell to multiple rows. For example, in the following table example, the first TH cell (Marks) spans on two rows. We use <th row