Hello,

I'm a newer web developer and I was working on a small project for myself. I defined a class called "garnish" and made a div that class. Then I placed a table in the div that contains my text. When I place text in the div, it is properly styled, but any text inside the table does not inherit the styling (actually the firebug inspector tells me it does, but it is clearly not properly styled). If I set the table to class garnish, I do receive proper styling... My question is, why doesn't my table inherit from the div? According to what I've read, this should work.

I stripped down my page to create a quick example of what I did, just look below.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>example</title>

    <STYLE type="text/css">
       body {
    font-family: Verdana, Geneva, Arial, san-serif;
    background-color: black;
    color: white;

}
   #allcontent {
    width: 800px;
    padding-top: 5px;
    padding-bottom: 5px;
    background-color: black;
    margin-left: auto;
    margin-right: auto;

    font-size: medium;
    font-weight: normal;

}
    div   {
    border-color: white;
    border-width: 3px;
    border-style: solid
     }
    .garnish {
        color: green;
    }
    </STYLE>

  </head>
  <body>

<h2>
    My Inventory
</h2>
    <div id="allcontent">
        <!--Title Section-->
        <div id="header">
            <h1>Example</h1>
        </div>

        <div id="pagecontent">




<div id="inventoryalcohol" class="alcohol">
    <form action="" method="POST">
        <table>
            <tr>
                <th>
                    <input type="radio" name="bacardi151" value="instock" checked="checked" />
                    <input type="radio" name="bacardi151" value="outofstock" />
                    <input type="radio" name="bacardi151" value="delete" />
                </th>
                <td>
                    Bacardi 151
                </td>
            </tr>
            <tr>
                <th>
                    <input type="radio" name="absolutcitron" value="instock" checked="checked" />
                    <input type="radio" name="absolutcitron" value="outofstock" />
                    <input type="radio" name="absolutcitron" value="delete" />
                </th>
                <td>
                    Absolut Citron
                </td>
            </tr>
            <tr>

                <th>
                    <input type="radio" name="jimbeamrye" value="instock" checked="checked" />
                    <input type="radio" name="jimbeamrye" value="outofstock" />
                    <input type="radio" name="jimbeamrye" value="delete" />
                </th>
                <td>
                    Jim Beam Rye
                </td>
            </tr>
        </table>
    </form>
</div>

<div id="inventorymixers" class="mixer">
<form action="" method="POST">
        <table>
            <tr>
                <th>
                    <input type="radio" name="orangejuice" value="instock" checked="checked" />
                    <input type="radio" name="orangejuice" value="outofstock" />
                    <input type="radio" name="orangejuice" value="delete" />
                </th>
                <td>
                    Orange Juice
                </td>
            </tr>
            <tr>
                <th>
                    <input type="radio" name="coke" value="instock" checked="checked" />
                    <input type="radio" name="coke" value="outofstock" />
                    <input type="radio" name="coke" value="delete" />
                </th>
                <td>
                    Coke
                </td>
            </tr>
            <tr>
                <th>
                    <input type="radio" name="7up" value="instock" checked="checked" />
                    <input type="radio" name="7up" value="outofstock" />
                    <input type="radio" name="7up" value="delete" />
                </th>
                <td>
                    7up
                </td>
            </tr>
        </table>
    </form>
</div>

<div id="inventorygarnish" class="garnish">
<form action="" method="POST">
        <table>
            <tr>
                <th>
                    <input type="radio" name="lemon" value="instock" checked="checked" />
                    <input type="radio" name="lemon" value="outofstock" />
                    <input type="radio" name="lemon" value="delete" />
                </th>
                <td>
                    Lemon
                </td>
            </tr>
            <tr>
                <th>
                    <input type="radio" name="lime" value="instock" checked="checked" />
                    <input type="radio" name="lime" value="outofstock" />
                    <input type="radio" name="lime" value="delete" />
                </th>
                <td>
                    Lime
                </td>
            </tr>
            <tr>
                <th>
                    <input type="radio" name="orange" value="instock" checked="checked" />
                    <input type="radio" name="orange" value="outofstock" />
                    <input type="radio" name="orange" value="delete" />
                </th>
                <td>
                    Orange
                </td>
            </tr>
        </table>
    </form>
</div>

        </div>

                <!--Footer Section-->
        <div id="footer">
           
        </div>

    </div>


  </body>
</html>

Dani AI

Generated

Good catch by — the problem is almost always the document mode, not CSS inheritance itself. Leaving out a proper standards DOCTYPE puts the page into quirks mode, which changes the browser's user-agent stylesheet and can make tables, form controls and other elements render with legacy defaults even though tools like Firebug show an inherited value in the computed panel. confirmed the DOCTYPE fix because switching to standards mode restores consistent inheritance and the expected painting behavior.

Notes and practical fixes:

  • Use a proper standards DOCTYPE as the very first line of the HTML so browsers run in standards mode. That alone usually fixes strange differences between parent and table text.

  • If you still see odd rendering, explicitly target table cells inside your class to force the color (this bypasses quirks/UA defaults):

    .garnish td,
    .garnish th {
        color: inherit;
    }

    Or set the color directly on those selectors if inheritance still misbehaves.

  • Remember replaced elements (inputs, radios) do not take the same color/appearance as normal text; wrap text in a label or style the surrounding cell instead.

  • Use dev tools to check document mode (most browsers show “Standards” vs “Quirks”), inspect the Styles panel to see the winning rule (not just the computed value), and validate the HTML to catch structural problems.

Also fix small typos in your CSS (for example, sans-serif spelling) — they can affect fallbacks.

Recommended Answers

All 3 Replies

if you waqnt it to work as expected you have to declare it as expected

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
commented: good spot AB - whether or not it solves his prob +6
commented: Thank you very much for the help. +0

Thanks, that was it.

hope its always something simple
Dos Vdanye

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.