Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

using css on div margins

Posted on 2016-07-15
3
Medium Priority
?
108 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

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

Open in new window

1
 
LVL 84

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…

609 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