Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Margins CSS

  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Margins CSS

    I'm creating a website I have little Css experience. I simply have an image that is my site (jpg file). I would like this image to have no margins, padding etc when it is viewed in the browser.

    When I open my browser (Safari) I get a huge amount of white space on the right side as well as at the bottom.

    I have attempted to select the body tag and add a css rule to have 0 borders or padding yet I am still left with a large amount of white space.

    Can anyone provide me some help with resolving my issue ? I would be willing to offer some of my illustration services for resolving this issue.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    .e {
    margin: 0px;
    padding: 0px;
    }
    body {
    margin: 0px;
    padding: 0px;
    }
    </style>
    </head>

    <body>

    <img src="2011 Website/home_lab.jpg" width="1522" height="1025" />
    </body>
    </html>

  • #2
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    628
    Thanks
    51
    Thanked 67 Times in 67 Posts
    To style your image you will have to either give it a class name and style the class or style all img tags using img { } (or you can, of course, style your image directly with the style attribute). Also, you should check to make sure there's no whitespace in your image; I've had times where it took me a while to realize that the reason I couldn't make the whitespace go away was because it was in the image and not part of the page itself.
    "Yeah science!"

  • #3
    Banned
    Join Date
    Jul 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks to both my friend. i also need it for image setting...

  • #4
    Regular Coder
    Join Date
    Jul 2011
    Location
    India
    Posts
    496
    Thanks
    3
    Thanked 57 Times in 56 Posts
    Use below given code. It will set padding and margin to 0 for all elements. If you want to padding or margin to any element, you can set for it.

    Code:
    *
    {
         margin:0;
         padding:0;
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •