Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • TABLE TAG

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 345
    Comment on it

    If we want to print data in the form of table in html we use TABLE tag. Table contain rows and columns.

    • For creating rows in table we use tr tag with in table tag.
    • For creating columns in table we use td tag with in tr tag.

    Syntax

    1. <table>
    2. <tr>
    3. <td>Row 1, Column 1</td>
    4. <td>Row 1, Column 2</td>
    5. </tr>
    6. <tr>
    7. <td>Row 2, Column 1</td>
    8. <td>Row 2, Column 2</td>
    9. </tr>
    10. </table>

    OUTPUT

    1. Row 1, Column 1 Row 1, Column 2
    2. Row 2, Column 1 Row 2, Column 2

    For adding border in this table we use border attribute it will put a border in all the cells. If we do not want a border then we can use border="0".

    eg:-

    1. <table border="1">
    2. <tr>
    3. <td>Row 1, Column 1</td>
    4. <td>Row 1, Column 2</td>
    5. </tr>
    6. <tr>
    7. <td>Row 2, Column 1</td>
    8. <td>Row 2, Column 2</td>
    9. </tr>
    10. </table>

    OUTPUT

    HTML Tables

    Row 1, Column 1 Row 1, Column 2
    Row 2, Column 1 Row 2, Column 2

    TABLE HEADING

    For giving table columns a heading we use th tag.

    eg:-

    1. <table border="1">
    2. <tr>
    3. <th>Name</th>
    4. <th>ADRESS</th>
    5. </tr>
    6. <tr>
    7. <td>suresh</td>
    8. <td>delhi</td>
    9. </tr>
    10. <tr>
    11. <td>pankaj</td>
    12. <td>lucknow</td>
    13. </tr>

    OUTPUT

    HTML Table Header

    Name ADDRESS
    Suresh Delhi
    Pankaj Lucknow

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: