Solved

using css on div margins

Posted on 2016-07-15
3
75 Views
Last Modified: 2016-07-15
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:

running the page in chrome
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?
0
Comment
Question by:maqskywalker
3 Comments
 
LVL 20

Accepted Solution

by:
Russ Suter earned 500 total points
ID: 41713322
Add this to your CSS
 body
 {
   margin: 0;
 }

Open in new window

1
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41713334
Russ is right.  <body> has a default margin of 4 to 8 pixels depending on the browser.
0
 
LVL 1

Author Closing Comment

by:maqskywalker
ID: 41713403
thanks
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question