Thursday, August 23, 2012

adding table tags and adding table to html pages

Adding tables in html :
Tables in html language are very useful to represent some data with detailed and
structured information.We use table tags to display a table in html.
<table> ......</table>

table tag starts and ends as you know how other html tags starts and closes.
there are three things or additional tags in table tag ,they are
<tr> -------- used to create new row in a table
<td> or <th>-used to create new column in a table.(th tags displays text in heading style or bold text).

Structure of table:
<table>
   <tr> <td>|column 1</td><td>| column 2</td></tr> ---new row
                   |                               |
                   |                               |
               new column 1          new column 2
</table>

I think its abit confusing with tr and td tags.I will make you clear with this.
A table consists of major border,then next rows and in each row there are columns.
first you create table,how?by creating table tags

<table>
</table>

table is created ,now you need to create two rows for example.
<table>
<tr>row 1</tr>
<tr>row 2</tr>
</table>

rows are created ,now you need to create two columns in each row,so use td tag for creating columns.
<table>
<tr><td>row 1 column 1</td><td>row 1 column 2</td></tr>

<tr><td>row 2 column 1</td><td>row 2 column 2</td></tr>

</table>

so i think you are clear with the concept of tables in html.

<html>
        <head>
          <h3>creating tables in html</h3>
        </head>
        <body>
          <table>
         <tr><td>row 1 column 1</td><td>row 1 column 2</td></tr>

          <tr><td>row 2 column 1</td><td>row 2 column 2</td></tr>

          </table>

        </body>
</html>  

Output:

creating tables in html

row 1 column 1row 1 column 2
row 2 column 1row 2 column 2

now you are done with handling tables and html at basic level.

<<back         next>>




   

No comments:

Post a Comment