Note that there are some explanatory texts on larger screens.

plurals
  1. POOdd margin on my divs, How do I solve this?
    text
    copied!<p>Here is the code i'm working on it's not a page it's a treasure hunt for what might be re-used in a page, I ran into this problem last week or so and I'm asking myself what the heck is this margin for a while here</p> <p>Let's picture that I can't use the <code>float:left;</code> tag for a reason, when I use <code>display:inline-block;</code> a weird margin apears on the elements (say divs) how do I fix it?</p> <p>Problem is on FF3, and IE8 never tested in other browsers but if it dos not work on these what will it work on?</p> <p><strong>Original Code</strong></p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Why does that happen&lt;/title&gt; &lt;style type="text/css"&gt; * {padding:0px; margin:0 auto; vertical-class:baseline; text-class:left;} body {padding:0px; margin:0 auto;} div{margin: 0 auto;} div div{margin: 0;} .body {background:#CCC; width:900px; } .red {background:#F00; height:300px; width:300px; display:inline-block; margin-left:0px;} .blue {background:#03F; height:300px; width:300px; display:inline-block; margin-left:0px;} .green {background:#090; height:300px; width:300px; display:inline-block; margin-left:0px;} .light-blue {background:#39F; height:300px; width:300px; display:inline-block; margin-left:0px;} .light-green {background:#9FC; height:300px; width:300px; display:inline-block; margin-left:0px;} .heavy-red {background:#C00; height:300px; width:300px; display:inline-block; margin-left:0px;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="body"&gt; &lt;div class="red"&gt;&lt;/div&gt; &lt;div class="blue"&gt;&lt;/div&gt; &lt;div class="green"&gt;&lt;/div&gt; &lt;div class="light-blue"&gt;&lt;/div&gt; &lt;div class="light-green"&gt;&lt;/div&gt; &lt;div class="heavy-red"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>Solved: solution is eliminate the spacing in the markup:</strong></p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Why does that happen&lt;/title&gt; &lt;style type="text/css"&gt; * {padding:0px; margin:0 auto; vertical-class:baseline; text-class:left;} body {padding:0px; margin:0 auto;} div{margin: 0 auto;} div div{margin: 0;} .body {background:#CCC; width:900px; } .red {background:#F00; height:300px; width:300px; display:inline-block; margin-left:0px;} .blue {background:#03F; height:300px; width:300px; display:inline-block; margin-left:0px;} .green {background:#090; height:300px; width:300px; display:inline-block; margin-left:0px;} .light-blue {background:#39F; height:300px; width:300px; display:inline-block; margin-left:0px;} .light-green {background:#9FC; height:300px; width:300px; display:inline-block; margin-left:0px;} .heavy-red {background:#C00; height:300px; width:300px; display:inline-block; margin-left:0px;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="body"&gt; &lt;div class="red"&gt;&lt;/div&gt;&lt;div class="blue"&gt;&lt;/div&gt;&lt;div class="green"&gt;&lt;/div&gt;&lt;div class="light-blue"&gt;&lt;/div&gt;&lt;div class="light-green"&gt;&lt;/div&gt;&lt;div class="heavy-red"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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