Pages

Useful things in HTML (Lesson 2)

How to create a Table in HTML?


      Today my HTML tutorial is about how to create a TABLE using HTML codes. Before you read this if you don't have any basic knowledge about HTML visit 1'st lesson and read it first, click HERE to see 1'st lesson. 

     Here is the tags that we use to create tables


TAG Description
< table >
Define a Table
< th > Define a Table Header
< tr >
Define a Table Row
< td > Define a Table Cell


Attributes support to HTML < table > tag

Attribute How to use Description
align
< table align = "
right /
left /
center /
justify /
     char " >
we use align to do visual alignment of
our TABLE.
border < table border = "<value in >"> Specified the border width. "0" mean no boarders.
cellpadding < table cellpadding = "<value>"> Specified the space between cell border and their content.
cellspacing < table cellspacing = "<value>"> Specified the space between cells.
bgcolor < table bgcolor = "<color code>"> Use to add colors to table background
background < table background = "<img src=""/>"> Use to add image to table background
width , height <table width="<value>" height="<value>"> Use to set Width and Height of table



Exercise - 1 


   Create Following table using HTML code.

Row 1 Cell 1 (HEADING 1) Row 1 Cell 2 (HEADING 2)
Row 2 Cell 1 Row 2 Cell 2

ANSWER


<table border="1">

<tr>
<th>Row 1 Cell 1 (HEADING 1) </th>

<th>Row 1 Cell 2 (HEADING 2) </th>

</tr>


<tr>

<td>Row 2 Cell 1 </td>

<td>Row 2 Cell 2 </td>
</tr>
</table> 


Exercise - 2

Create following table using HTML code

Column 1 Colmn 2 Colmn 3
Row 1

Answer


<table align = "center" cellspacing = "10" cellpadding = "4" bgcolor = "#82E0AA">

<tr>
<th> Column 1 </th>
<th> Colmn 2 </th>
<th> Colmn 3 </th>
</tr>

<tr>
<td> Row 1 < /td >
</tr>
</table>


Stay with nisalsworld for more tutorials