Sunday, February 17, 2013

Tables in HTML


<table>:
Table tag is used to generate a tabular format in HTML.
Two sub tags are used with table tag:
1.    <tr> (For table Rows)
2.    <td>  (For table Columns)
Some attributes which are used with table or its sub tags:
1.    Border=”size” (Used to assign border size by default it is zero also used with img tag)
Note: Table will not visible till we assign any border.
2.    Bordercolor=”color” (Used to change border color)
3.    Bgcolor=”color” (Used to change table’s background color)
4.    Height=”size” Width=”size”
5.    Align=”L/C/R”
6.    Colspan=”” (Used to merge columns)
7.    Rowspan=””(Used to merge rows)

·       Write a program to generate the following output:

1
2
3
4
5
6
7
8
9

<HTML>
            <BODY>
            <table border=”1”>
                        <tr>
                                    <td>1</td>
                                    <td>2</td>
                                    <td>3</td>
                        </tr>
                        <tr>
                                    <td>4</td>
                                    <td>5</td>
                                    <td>6</td>
                        </tr>
                        <tr>
                                    <td>7</td>
                                    <td>8</td>
                                    <td>9</td>
                        </tr>
            </table>
            </BODY>
</HTML>

·       Write a program to generate the following output:

1
2
3
4
5

<HTML>
            <BODY>
            <table border=”1”>
                        <tr>
                                    <td colspan=”3”>1</td>
                        </tr>
                        <tr>
                                    <td rowspan=”2”>2</td>
                                    <td colspan=”2”>3</td>
                        </tr>
                        <tr>
                                    <td>4</td>
                                    <td>5</td>
                        </tr>
            </table>
            </BODY>
</HTML>

0 comments:

Post a Comment

Powered by Blogger.