Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

using css on div margins

I have this html code

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        #mydiv {
            background-color: #304bee;
            height: 400px;
            width: 100%;
        }

        #mytable {
            height: 100px;
            width: 200px;
            border: 1px solid #00ff00;
            /* center horizontally */
            margin-left: auto;
            margin-right: auto;
        }
    </style>
</head>
<body>
    <div id="mydiv">
        <table id="mytable">
            <tr>
                <td>your table
                </td>
            </tr>
        </table>
    </div>
</body>
</html>

Open in new window


When I run that in google chrome it looks like this:

User generated image
I set the width of my div to 100% but notice how there still some space to the left and right of the div.

How would i get rid of the space to the left and right of the div?
ASKER CERTIFIED SOLUTION
Avatar of Russ Suter
Russ Suter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Russ is right.  <body> has a default margin of 4 to 8 pixels depending on the browser.
Avatar of maqskywalker
maqskywalker

ASKER

thanks