Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The reason is the default CSS styles as determined by your browser.</p> <ul> <li><code>input</code> and <code>select</code> have default colors/sizes/padding etc.</li> <li>Most other elements use <code>inherit</code> for color and size.</li> <li>Another example is the font-size of <code>table</code> which is fixed and not inherited by default, and must be overridden by the developer.</li> </ul> <p>Try this example HTML:</p> <pre><code>&lt;html&gt; &lt;style type="text/css"&gt; body { color:red; font-size:36px; } &lt;/style&gt; &lt;body&gt; Hello &lt;input type="text" value="test value"/&gt; &lt;table&gt;&lt;tr&gt;&lt;td&gt;cell value&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>You will see that the <code>font-size</code> and <code>color</code> were not inherited by the <code>input</code>. Also, the cell value stayed at the default font size. Now add the following CSS to the <code>style</code> block:</p> <pre><code>input { color:inherit; font-size:inherit; } table { font-size:inherit; } </code></pre> <p>You'll see that they inherit as you expected now.</p> <p><strong>What you really want to do is use a reset stylesheet</strong>. Tables are just one element that has a default style attached that isn't desirable for many developers, and every browser might be slightly different. This is why many make use of <strong>reset css</strong> stylesheets. These stylesheets reset most elements to uniform sizes and zero margins, padding, etc. Some are more extreme than others. See <a href="http://meyerweb.com/eric/tools/css/reset/" rel="noreferrer">http://meyerweb.com/eric/tools/css/reset/</a> or <a href="http://www.google.com/search?q=reset+css" rel="noreferrer">Google</a> for an example.</p> <p>Since most reset stylesheets don't make colors of <code>input</code> and <code>select</code> inherit (most developers don't want them to inherit and instead want to explicitly set size/color), you should set them in your stylesheet:</p> <pre><code>input, select { ... } </code></pre> <p><strong>Be careful</strong> with <code>* { ... }</code> for <em>any</em> purpose (as suggested by the other answer). This <strong>breaks</strong> the "cascading" part of CSS and will cause rules not to cascade as you would expect in nested elements. If you use <code>* { color:red; }</code> and then have the following HTML:</p> <pre><code>&lt;h1 style="color:green;"&gt;Hello &lt;i&gt;world&lt;/i&gt;&lt;/h1&gt; </code></pre> <p>You will end up with a green <strong>Hello</strong> and a <em>red</em> <strong>world</strong>. (Because the <code>&lt;i&gt;</code> matches <code>*</code>. Any new element will reset the style back to red, and color no longer cascades at all!)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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