My biggest gripe with HTML is that line breaks add a tiny bit of space between elements. (jsFiddle.)
This can screw up layouts where child elements are sized to exactly fit their parents.
I read somewhere that you can remove this implicit padding – while still keeping the code somewhat legible – by using comments like this:
<!--
--><div>Foo</div><!--
--><div>Bar</div><!--
--><div>And so on...</div><!--
-->
This works, but I feel like there has to be a better solution. What other ways are there to work around the line-break padding?
That isn’t “a little bit of space”, but literally a space character. You are using
display: inline-blockto align your elements horizonally, and that’s how “inline” works.If you want to use
inline-blockyou need to remove the white space between the elements as you are doing it.Otherwise you can use one of the other methods to horizontally align, for example floating or
display: table-cell.