How to remove page margin

14,686

You need to specifically set margin and padding to 0 on the "body" element.

just try this in your css:

body { margin: 0; padding: 0; }
Share:
14,686
Rameez
Author by

Rameez

Updated on June 04, 2022

Comments

  • Rameez
    Rameez almost 2 years

    the space is display between page margin and nevigation bar, So how to delete this space

    css code

    #topnav ul
    {
    
        list-style-type:none;
        margin:0;
        padding:0;
    
        overflow:hidden;
    }
    
    #topnav li
    {   
    
        float:left;
        display:inline;
    
    
    
    }
    
    
    
    #topnav a:link,
    #topnav a:visited
    {
        display:inline-block;
        width:110px;
        font-weight:bold;
        font-family:calibri;
    
        color:#FFFFFF;
        background-color:#98bf21;
        text-align:center;
        padding:3px;
        text-decoration:none;
        text-transform:uppercase;
    }
    
    #topnav a:hover,
    #topnav a:active
    {
        background-color:#7A991A;
    }
    

    html code

    <ul id="topnav">
        <li id="topnav"><a  href="#home">Home</a></li>
        <li id="topnav"><a  href="#news">OPD</a></li>
        <li id="topnav"><a  href="#news">IPD</a></li>
        <li id="topnav"><a  href="#news">Infrastucture</a></li>
        <li id="topnav"><a  href="#news">Gallery</a></li>
        <li id="topnav"><a  href="#news">Media</a></li>
        <li id="topnav"><a  href="#contact">Site Map</a></li>
        <li id="topnav"><a  href="#about">About</a></li>
        <li id="topnav"><a  href="#about">Nursing</a></li>
    </ul>
    
  • Stein G. Strindhaug
    Stein G. Strindhaug almost 13 years
    Try using firebug, dragonfly or similar to see which element is having padding or margin. For internet explorer (some version, I think) the html element may also have margin/padding.
  • Mohag519
    Mohag519 almost 13 years
    Is the margin to the left of the ul? in that case it might be because of the automatic indentation of li's. try to fiddle with the CSS-property "list-style-position". But really, an demo on JSfiddler would let me solve it in notime.