Table in HTML

 Table in HTML

Click on this Image for Video Tutorial.







To create a table in HTML, <TABLE> tag is used.


<TABLE> tag contains <TH>, <TR>, <TD> and <CAPTION> tags.


<TH> tag is used for Table Header.

<TR> tag for Table Row and <TD> tag is used for Table Data.

<CAPTION> tag is used to specify the title for the table.


Attributes of <TABLE> Tag-


border: - This attribute specifies the thickness of border around

a table in pixels.


bordercolor: - It is used to set the border color of a table.


bgcolor: - It specifies the background color of a table.


cellpadding: - Set the distance between the cell content and cell boundaries in pixels. The default value is 2.


cellspacing: - Used to set the minimum distance between two adjacent cells in pixels. The default value is 2.


align: - To set alignment of table. It can be left, center and right.


height: - It specifies table height in pixels.


width: - It specifies table width in pixels.


EXAMPLE OF TABLE:-

<HTML>

<HEAD> 

<TITLE> TABLES IN HTML</TITLE> 

</HEAD>

<BODY>

<TABLE BORDER=3 BORDERCOLOR="RED" BGCOLOR="GREEN" HEIGHT=200

WIDTH=450 CELLPADDING=25 CELLSPACING=50>


<CAPTION> Student's Detail</CAPTION>

<TR>

    <TH> ROLL NO</TH> 

    <TH> NAME</TH> 

    <TH> AGE</TH>

    <TH>CLASS</TH>

</TR>


<TR>

    <TD>1 </TD> 

    <TD> ATUL </TD> 

    <TD> 15 </TD> 

    <TD> 10 </TD>

</TR>

<TR>

    <TD>2 </TD> 

    <TD> AMAN </TD> 

    <TD> 14</TD> 

    <TD> 9 </TD>

</TR> 

</TABLE> 

</BODY> 

</HTML>


Attributes of <TR>,<TD> and <TH> tags:-

bordercolor: - It is used to set the border color of row, cell.

bgcolor: - It is used to set the background color of row, cell.

align:- To set the alignment of content in cell.

Valign: - sets the vertical alignment of data in column.

colspan: - It combines cells horizontally.

rowspan: - It combines cells vertically.


Click on this Image for Video Tutorial.




<Html>

<Head>

<Title> Table in HTML</Title>

</Head>

<Body>

<Table border=3 align= "center">

<Caption> Weather Station</Caption>

<TR>

<TH Rowspan=2>Station</TH>

<TH Colspan=2> Temperature</TH>

<TH Rowspan=2> Humidity</TH>

<TH Rowspan=2> weather</TH>

</TR>

<TR>

<TH>Max</TH>

<TH>Min</TH>

</TR>

<TR>

<TD>USA</TD>

<TD>24</TD>

<TD>19</TD>

<TD>60%</TD>

<TD>cloudy</TD>

</TR>

<TR>

<TD>Germany</TD>

<TD>5</TD>

<TD>-1</TD>

<TD>70%</TD>

<TD>Rainy</TD>

</TR>

</Table>

</Body>

</Html> 




Example 2:-

<HTML>

<HEAD> 

<TITLE> USE OF ROWSPAN AND COLSPAN</TITLE> </HEAD>

<BODY> 

<TABLE BORDER=5>

    <TR> 

        <TH COLSPAN=4 ALIGN="CENTER"> CLASS 10th</TH>         </TR>

      <TR>

         <TH ROWSPAN=3> Details</TH>

        <TH> R. NO. </TH> 

        <TH>NAMES</TH> 

         <TH>MARKS</TH>

    </TR>

    <TR>

            <TD>1</TD> 

            <TD>MANOJ</TD> 

            <TD>91</TD>

    </TR>

    <TR>

            <TD>2</TD> 

            <TD>AMIT</TD> 

            <TD>90</TD>

       </TR>

</BODY> 

</HTML>






Post a Comment

Previous Post Next Post