skip to Main Content

I want to create a table in html and I mantion my code below.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Table</title>
</head>
<body>
    
</body>
</html>

This is my expected output:

Column A Column B
Cell 1 Cell 2
Cell 3 Cell 4

3

Answers


  1. Try this for make table,

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Table</title>
    </head>
    <body>
        <table>
            <tr>
              <th>Column A</th>
              <th>Column B</th>
            </tr>
            <tr>
              <td>Cell 1</td>
              <td>Cell 2</td>
            </tr>
            <tr>
              <td>Cell 3</td>
              <td>Cell 4</td>
            </tr>
        </table>
    </body>
    </html>
    
    Login or Signup to reply.
  2. Copy This and Run This in Your HTML File
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Table</title>
    </head>
    <body>
        <table border="1">
            <tr>
            <th>Column A</th>
            <th>Column B</th>
        </tr>
        <tr>
            <td>Cell 1</td>
            <td>Cell 2</td>
        </tr>
        <tr>
            <td>Cell 3</td>
            <td>Cell 4</td>
        </tr>
        </table>
    </body>
    </html>
    Login or Signup to reply.
  3. You can learn how to create html table here.

    But I’ll leave this sample so you can move on.

    table{
        width: 70%;
        border: 1px solid black;
        border-collapse: collapse;
    }
    th, td{
        border: 1px solid black;
        text-align: left;
        padding: 8px;
    }
    th{
        background-color: hsl(210,8%,95%);
    }
    <table>
        <thead>
            <tr>
                <th>Column A</th>
                <th>Column B</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Cell 1</td>
                <td>Cell 2</td>
            </tr>
            <tr>
                <td>Cell 3</td>
                <td>Cell 4</td>
            </tr>
        </tbody>
    </table>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search