0

For some reason there are horizontal gaps between the <li> elements in this example, and I simply cannot fathom why they are there.

Markup

<ul>
    <li>
        Stuff
    </li>
    <li>
        Things
    </li>
    <li>
        /dev/null
    </li>
    <li>
        Use Jquery!
    </li>
</ul>

CSS

ul {
  margin:0;
  padding:0;
  height:50px;
}
ul > li {
  display:inline-block;
  background-color:silver;
  height:100%;
  width:20%;
  max-width:300px;
  list-style-type:none;
  text-align:center;
    line-height:50px;
}

What is causing these gaps?

ul {
  margin:0;
  padding:0;
  height:50px;
}
ul > li {
  display:inline-block;
  background-color:silver;
  height:100%;
  width:20%;
  max-width:300px;
  list-style-type:none;
  text-align:center;
    line-height:50px;
}
<ul>
    <li>
        Stuff
    </li>
    <li>
        Things
    </li>
    <li>
        /dev/null
    </li>
    <li>
        Use Jquery!
    </li>
</ul>
gandalf3
  • 1,516
  • 4
  • 22
  • 35
  • @Xufox Whoa, that worked! Why does whitespace in the html source affect the output? – gandalf3 Jul 31 '15 at 19:11
  • There were no whitespaces at that point in the HTML source. Line breaks cause this. I don’t know why. – Sebastian Simon Jul 31 '15 at 19:13