-1

I a div with a class of "social-icons" this is a container for my ul list in between my li I'm seeing a padding that I can't seem to get rid of.

Please see screenshot attached. I have tried many things to get rid of this problem, I even set a class to my images and set margin and padding to 0 using css.

Thanks for your help in advance.

Padding or margin issue screenshot

.social-icons {
    float: right;
    width: auto;
    height: 24px;
    padding: 0;
    margin: 13px 0 0 80px;
    background-color: black;
}

.social-icons ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}

.social-icons ul li {
    display: inline;
    margin: 0;
    padding: 0;
}

.social-icon {
    margin: 0;
    padding: 0;
}
<div class="social-icons">
    <ul>
        <li><a href="#"><img src="images/Twitter.png" class="social-icon" alt="Twitter icon" height="24" width="24"></a></li>
        <li><a href="#"><img src="images/Facebook.png" class="social-icon" alt="Facebook icon" height="24" width="24"></a></li>
        <li><a href="#"><img src="images/Google-plus.png" class="social-icon" alt="Google+ icon" height="24" width="24"></a></li>
    </ul>
</div>
Szabolcs Páll
  • 1,402
  • 6
  • 25
  • 31
Richard Rodgers
  • 617
  • 1
  • 7
  • 17

2 Answers2

1

Set font-size: 0px; to the parent div.

Please take a look at this question.

Community
  • 1
  • 1
Berendschot
  • 3,026
  • 1
  • 21
  • 43
  • This is a bad practice (a hack)! (Also the link is broken.) – Szabolcs Páll Dec 17 '15 at 16:34
  • Link is fixed. But I consider it more like a bug in most browsers than bad practice. – Berendschot Dec 17 '15 at 16:59
  • It not. The gap is the whitespace between the two element, and logically you cannot tell the difference between two words in two span with different background color with a transarent space between them, or two inline(-block)-ed list items with icons in them. You could just as well write you whole html in one single line, resulting in no whitespace between your tags, or you could make this change to (minify) your html server side, so you can avoid these "problems" in the first place. So no, its not a bug in (all) browsers, instead its simply not understanding how html rendering works! – Szabolcs Páll Dec 18 '15 at 07:11
-1

Leave the closing </li> tag out.

<li>first
<li>second
<li>third

It's valid html (not valid as xhtml) and resolves the issue that is caused by the whitespace (linebreak + tabs) between inline elements, because the browser autoinsert the closing tag right before the next opening.

You also need to change from inline to inline-block, to make the browser handle it correctly.

Szabolcs Páll
  • 1,402
  • 6
  • 25
  • 31