Skip to main content
Inspiring
January 22, 2019
Answered

simple padding problem - can't solve :-(

  • January 22, 2019
  • 2 replies
  • 964 views

This is very simple SORRY but for some reason I keep getting this wrong.

I have created a div with a red background and I want to get rid of the margin on the left and right ie the padding.

In dreamweaver I set it to 0 padding but this does not work

not sure what I am doing wrong?

Many thanks

---------

----------

<!doctype html>

<html>

<style>

.header {

    margin: 0;

    padding: 0;

    background-color: #FF0004;

}

    @media (max-width:768px) and (min-width:401px){

}

@media (max-width:400px){

}

</style>

<head>

<meta charset="UTF-8">

<title>Untitled Document</title>

<link href="css/header-general.css" rel="stylesheet" type="text/css">

</head>

<body>

<div class="header">Content for New Div Tag Goes Here</div>

</body>

</html>

---------

---------

    This topic has been closed for replies.
    Correct answer osgood_

    https://forums.adobe.com/people/tim+cross  wrote

    This is very simple SORRY but for some reason I keep getting this wrong.

    I have created a div with a red background and I want to get rid of the margin on the left and right ie the padding.

    It's the body tag that has a default margin that isn't allowing your div to go 100% left to right, without a small space either side.

    Clear the body tags default margin:

    body {

    margin: 0;

    }

    or you can do as Ben suggests and clear the margin/padding on all elements.

    2 replies

    osgood_Correct answer
    Legend
    January 22, 2019

    https://forums.adobe.com/people/tim+cross  wrote

    This is very simple SORRY but for some reason I keep getting this wrong.

    I have created a div with a red background and I want to get rid of the margin on the left and right ie the padding.

    It's the body tag that has a default margin that isn't allowing your div to go 100% left to right, without a small space either side.

    Clear the body tags default margin:

    body {

    margin: 0;

    }

    or you can do as Ben suggests and clear the margin/padding on all elements.

    tim crossAuthor
    Inspiring
    January 22, 2019

    Thank You everyone that solves the issue. I understand now :-)

    ALsp
    Legend
    January 22, 2019

    Just to be clear, there is no default margin or padding assigned to a DIV.

    BenPleysier
    Community Expert
    Community Expert
    January 22, 2019

    That is because most elements have a margin and or padding as default.

    The best way is to remove the padding and margins from all elements suing the wildcard as in

      * {

        margin: 0;

        padding: 0;

      }

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!