
- #Css method for collapsing text blocks how to
- #Css method for collapsing text blocks download
- #Css method for collapsing text blocks free
So, I checked the mdn-letter-spacing and found this: If you are using Firefox(60.0.2),IE10 or Edge, what you see might be: NOTE: I have modified to accommodate to inherit letter-spacing when a wrapper has a child wrapper. You will NOT have the need to go back to the css, and add another css rule, for your new inline blocks.Īlso note the > (greater than sign) this means that */all children should be inline-block.
#Css method for collapsing text blocks download
It's in Google Drive so you'll need to click File > Download to save it to your computer. The css declaration is included: zipped zero-width space font. Here’s a download to the font I just cooked up in font-forge and converted with FontSquirrel webfont generator. Url('./Fonts/zerowidthspaces.svg#NoSpace') format('svg') Url('./Fonts/zerowidthspaces.ttf') format('truetype'), Url('./Fonts/zerowidthspaces.woff') format('woff'), Src: url('./Fonts/zerowidthspaces.eot?#iefix') format('embedded-opentype'), Once you declare the font, you just change the font-family on the container and back again on the children, and voila. It’s called a custom font with zero-width spaces, which allows you to collapse the whitespace (added by the browser for inline elements when they're on separate lines) at the font level using a very tiny font. There’s actually a really simple way to remove whitespace from inline-block that’s both easy and semantic. This is the same answer I gave over on the related: Display: Inline block - What is that space? This way you will have a readable and correctly indented code.Īnd, as a positive side effect, the HTML source, although infested by empty comments, Use HTML comments to connect the end of one div to the begin of the next one! That is not readable, hard to maintain and understand, etc. It is absolutely not thinkable to inline all that stuff, it would mean (Do something here with the pushed object.) what if I'm generating my divs inside Taglibs loops ( Struts2, JSTL, etc.) ? Then I decided to remove the spaces (this answers is about this argument) between the inline-block divs from my HTML source ( JSP),īut, wait a minute. OK, although I've upvoted both the font-size: 0 and the not implemented CSS3 feature answers,Īfter trying I found out that none of them is a real solution.Īctually, there is not even one workaround without strong side effects. Now that I've gone and bored you to death with "one thousand different ways to remove whitespace, by thirtydot", hopefully you've forgotten all about font-size: 0. Or, you can even skip certain closing tags entirely (all browsers are fine with this): Or, if you are using using PHP or similar: Let's go on a magical journey of different ways to remove the whitespace, with some new HTML: Will appending another element with JavaScript add whitespace? No, not if you do it properly. You do sometimes have to carefully consider where whitespace will come from. I remove the whitespace in the HTML between the inline-block elements. This is what I, as a reasonably experienced web developer, actually do to solve this problem:
#Css method for collapsing text blocks free
However, while this is a reasonable solution if you specifically need a CSS only fix, it's not what I recommend if you're free to change your HTML (as most of us are). Most of the possible issues with relative font sizes are not complicated to fix. Safari 5 is nearly a dead browser ( 0.33%, August 2015). It does not work in Safari 5, but it does work in Safari 6. This works in recent versions of all modern browsers. The solution I had in my initial answer was to add font-size: 0 to the parent element, and then declare a sensible font-size on the children. It is possible to solve this problem with CSS alone, but there are no completely robust CSS fixes.
#Css method for collapsing text blocks how to
How to remove the space between inline-block elements? I was hopingįor a CSS solution that doesn't require the HTML source code to be

Let's not forget the actual question that was asked:

Since this answer has become rather popular, I'm rewriting it significantly.


Alternatively, you should now use flexbox to achieve many of the layouts that you may previously have used inline-block for:
