Solved

using css on div margins

Posted on 2016-07-15
3
86 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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 …

730 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