Center Html table inside div using center tag

Last Reply 8 days ago By dharmendr

Posted 8 days ago

I have one div which contain one table ,but i want to place this table at the center of div,so whenever i am potback my page it will show me in center.I have tried below code.

<div style="margin: 0 auto">
     <table style="align-content: center" border="0" cellpadding="0" cellspacing="0">
         <tr>
            <td style="text-align: right">Id:
            </td>
You are viewing reply posted by: dharmendr 8 days ago.
Posted 8 days ago

Hi babuk,

You can use center tag to allign the table at center inside the div.

Refer the below sample html.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        body
        {
            font-family: Arial;
            font-size: 10pt;
        }
        table
        {
            border: 1px solid #ccc;
        }
        table th
        {
            background-color: #F7F7F7;
            color: #333;
            font-weight: bold;
        }
        table th, table td
        {
            padding: 5px;
            border-color: #ccc;
        }
    </style>
</head>
<body>
    <div style="margin: 0 auto">
        <center>
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="text-align: right">
                        Id:
                    </td>
                    <td>
                        1
                    </td>
                </tr>
            </table>
        </center>
    </div>
</body>
</html>

Demo

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html