30-03-2012, 10:17 AM
HTML TABLES
HTML TABLES.ppt (Size: 853 KB / Downloads: 36)
TABLE
Why tables are important:-
To maintain the elements of your website
To be creative with the design of pages
To separate & organize different formatting styles
Basic Table tags:
<table> To begin table<tr> Defines beginning of first row<td> Defines beginning of the cell</td> To complete cell</tr> To complete row</table> To end table
The General Table Syntax
<table>
<tr>
<td> First Cell </td>
<td> Second Cell </td>
</tr>
<tr>
<td> Third Cell </td>
<td> Fourth Cell </td>
</tr>
</table>
Creating Headings with the <th> Tag
HTML provides the <th> tag for table headings.
Text formatted with the <th> tag is centered within the cell and displayed in a boldface font.
The <th> tag is most often used for column headings, but you can use it for any cell that you want to contain centered boldfaced text.
Adding Table Headings to the Table
<html>
<head><title>my table</title></head>
<body>
<table >
<tr >
<th>Sahil</th>
<th>Talwar</th>
</tr>
<td>MCA</td>
<td>10805845</td>
</table>
</body>
</html>
Adding a Table Border
By default, browsers display tables without table borders.
A table border can be added using the border attribute to the <table> tag.
The syntax for creating a table border is: <table border=“value”>
value is the width of the border in pixels
Table Border
<html>
<head><title>my table</title></head>
<body>
<table border=“3”>
<tr >
<th>Sahil</th>
<th>Talwar</th>
</tr>
<td>MCA</td>
<td>10805845</td>
</table>
</body>
</html>
Controlling Cell Spacing
The cellspacing attribute controls the amount of space inserted between table cells.
The syntax for specifying the cell space is:
<table cellspacing=“value”>
value is the width of the interior borders in pixels
the default cell spacing is 2 pixels
Cell spacing refers to the space between the cells.
Defining Cell Padding
To control the space between the table text and the cell borders, add the cellpadding attribute to the table tag.
The syntax for this attribute is:
<table cellpadding=“value”>
value is the distance from the table text to the cell border, as measured in pixels
the default cell padding value is 1 pixel
Cell padding refers to the space within the cells.
Defining the Table Size
The syntax for specifying the table size is:
<table width=“size” height=“size”>
size is the width and height of the table as measured in pixels or as a percentage of the display area
Table Size
<html>
<head>
<title>my table</title>
<head>
<body>
<table border=10 align= "center" height ="100" width="300">
<tr >
</tr>
<td>Sahil</td>
<td>Talwar</td>
</table>
</body>
</html>