Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I remove the space between inline-block elements?
    primarykey
    data
    text
    <p>Given this HTML and CSS:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>span { display:inline-block; width:100px; background-color:palevioletred; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt; &lt;span&gt; Foo &lt;/span&gt; &lt;span&gt; Bar &lt;/span&gt; &lt;/p&gt;</code></pre> </div> </div> </p> <p>As a result, there will be a 4&nbsp;pixel wide space between the SPAN elements.</p> <p><strong>Demo:</strong> <a href="http://jsfiddle.net/dGHFV/" rel="noreferrer">http://jsfiddle.net/dGHFV/</a></p> <p>I understand why this happens, and I also know that I could get rid of that space by removing the white-space between the SPAN elements in the HTML source code, like so:</p> <pre class="lang-html prettyprint-override"><code>&lt;p&gt; &lt;span&gt; Foo &lt;/span&gt;&lt;span&gt; Bar &lt;/span&gt; &lt;/p&gt; </code></pre> <p>However, I was hoping for a CSS solution that doesn't require the HTML source code to be tampered with.</p> <p>I know how to solve this with JavaScript - by removing the text nodes from the container element (the paragraph), like so:</p> <pre class="lang-js prettyprint-override"><code>// jQuery $('p').contents().filter(function() { return this.nodeType === 3; }).remove(); </code></pre> <p><strong>Demo:</strong> <a href="http://jsfiddle.net/dGHFV/1/" rel="noreferrer">http://jsfiddle.net/dGHFV/1/</a></p> <p>But can this issue be solved with CSS alone?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload