Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting the height of a div using CSS
    text
    copied!<p>I'm having a problem with setting the height of <code>&lt;div&gt;</code> tags using CSS.</p> <p>I'm using the following CSS &amp; HTML code.</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 charset="utf-8" /&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;style&gt; body, p, b, ul, li, div { padding:0; margin:0; border:0; font-family:Arial, Helvetica, sans-serif; } div { display:block; } #ph_container { margin:0 auto; width:980px; height:auto; border: 1px solid #00CC33; clear:both; background: #F0F0F0; } #cp_search { height:100px; clear:both; margin:10px 0px 0px 0px; border: 1px solid #0099FF; } #cp_search_ex { clear:both; background:none; margin-top:5px; margin-left:27px; } #cp_search_tx { width:210px; float:left; /*try here whitout float and see the difference that I want to get*/ margin:0px; background:none; } .txtx { color: #000000; text-decoration:none; font-size:13px; font-weight:bold; } &lt;/style&gt; &lt;body&gt; &lt;div id="ph_container" class="space"&gt; &lt;div id="cp_search"&gt; &lt;div id="cp_search_ex" class="space"&gt; &lt;div id="cp_search_tx" class="txtx" &gt;SEARCH&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My problem is that the parent <code>div id="cp_search_ex"</code> doesn't get the height of the <code>div id="cp_search_tx"</code> which is inside it, it has the <code>height: 0px</code>.</p> <p>I want the <code>div id="cp_search_ex"</code> to take the height from the <code>div id="cp_search_tx"</code>?</p> <p>I wrote a comment in the CSS code please follow.</p>
 

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