SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    3
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post unable to get rid of spaces around an image using DIV

    Hi,

    I am trying to get rid of white space around an image using DIV..read through umpteen posts and tried all sorts - it simply does not work whatever I try..the red border still appears at the bottom of the image.

    Any help would be greatfully received.

    HTML Code is:
    -------------------------------------------------------------------
    <!DOCTYPE html>
    <html lang="en">
    <head><title>Title</title><meta charset="utf-8"/>

    <link rel="stylesheet" href="css/6.css" type="text/css" media="screen"/>

    </head>

    <div id="first_logo_container"><img src="images/Klogo1.jpg" /></div>

    </body>
    </html>
    -------------------------------------------------------------------------------

    CSS code for 6.css is:
    -------------------------------------------------------------------------------
    body {
    }

    #first_logo_container {
    float:left;
    background-color:red;
    margin: 0px;
    padding: 0px;
    outline: none;
    border: 0px;
    }
    --------------------------------------------------------------------------------

  2. #2
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,838
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    @Anuraggb ;

    Welcome to the forum.

    Try adding line-height:0 to the CSS
    Last edited by John_Betong; Mar 30, 2013 at 08:59. Reason: spelling: not my fortay :(
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Posts
    85
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    or you could do this:
    Code:
    #first_logo_container img{ float: left; }

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,203
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Hi Anuraggb. Welcome to the forums.

    This is a common issue, and you need to add this to your CSS to fix it:

    Code:
    img {vertical-align: bottom;}
    An alternative is

    Code:
    img {display: block;}
    but the issue is really caused by the default space that is put under images by the browser. This is because, by default, an image aligns with the baseline of any text that might sit beside it, so there is space below it for the descenders of the text.

  5. #5
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    3
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Thank you everyone..the "line-height:0" has done the trick, I will also try all other

    Quote Originally Posted by ralph.m View Post
    Hi Anuraggb. Welcome to the forums.

    This is a common issue, and you need to add this to your CSS to fix it:

    Code:
    img {vertical-align: bottom;}
    An alternative is

    Code:
    img {display: block;}
    but the issue is really caused by the default space that is put under images by the browser. This is because, by default, an image aligns with the baseline of any text that might sit beside it, so there is space below it for the descenders of the text.

  6. #6
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    3
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you everyone..the "line-height:0" has done the trick for me..I will also try all other suggestions to see how it works..much appreciated!


Tags for this Thread

Bookmarks

Posting Permissions

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