CSS-TABLE

TABLE

Add .css file

.tre{
border-color:yellow ;
}
table
{
border: 2px solid red;
}
th
{
background-color: blue;
text-align: center;
}
tr,td
{
padding: 15px;
}
tr:nth-child(odd) {
background-color:turquoise;
}
tr:nth-child(even) {
background-color:#87CEEB;
}

Note:-

  • :nth-child selector being used to select specific child elements.
  • We've used the odd(for odd place as 1,3,5 etc) and even(for enen place as 2,4,6,8 etc) keywords in our code,

  • Add form.html file

    <html>
    <Head>
    <tittle>Table tag </tittle>
    </Head>
    <body>
    <table border="1">
    <tr>
    <td>shivansh</td>
    <td>barilly</td> </tr>
    <tr>
    <td>mayank</td>
    <td>Noida</td>
    </tr>
    <tr>
    <td>tom</td>
    <td>Delhi</td> </tr>
    </table>
    </body>
    </html>

    Output:-

    Name Address
    Shivansh Barilly
    mayank Noida
    tom Delhi