Skip to content

Instantly share code, notes, and snippets.

@mo-gr
Created August 1, 2013 15:08
Show Gist options
  • Save mo-gr/6132269 to your computer and use it in GitHub Desktop.
Save mo-gr/6132269 to your computer and use it in GitHub Desktop.
Whitespace doesn't matter in HTML – unless it does
.wrapper {
width: 253px;
background: red;
box-sizing: border-box;
margin: 10px
}
a {
display: inline-block;
width: 50%; /* set to 49% to see the gap */
background: green;
/* float: left;*/ /*solution*/
}
.last {
background: yellow;
}
I just learned that the whitespace between two <code>inline-block</code> tags is relevant for their spacing.
<div class="wrapper">
<a class="first">A</a>
<a class="last">B</a>
</div>
<div class="wrapper"><a class="first">A</a><a class="last">B</a></div>
<br/>
<em>same as the whitespace between</em> <strong>these two tags</strong>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment