Link to home
Start Free TrialLog in
Avatar of Starr Duskk
Starr DuskkFlag for United States of America

asked on

TD padding

I have one table that I want the style to have padding of 3 points on all 4 points. If I put this in the td style, it works. If I put it in a class and add it to the td coding, it doesn't. If I put it in a style and add to coding, it doesn't. HOw do I fix this?

Doesn't work:
 <td valign="top" align="left" width="100%" style="padding: 3px 3px 3px 3px;">

Open in new window


doesn't work:
<td valign="top" align="left" class="tdHome">

Open in new window


.tdHome td
{
    vertical-align: top;
    padding: 3px 3px 3px 3px;
}

or 

#tdHome td
{
    vertical-align: top;
    padding: 3px 3px 3px 3px;
}

Open in new window


Does work:
td
{
    vertical-align: top;
    padding: 3px 3px 3px 3px;
}

Open in new window


But I don't want to put it in the 'td' because I only want the padding for THIS table, not for every table.

thanks.
SOLUTION
Avatar of SSupreme
SSupreme
Flag of Belarus image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, if you specifically want 3px and no more, you should add cellPadding="0" within your <table> tag
Avatar of Starr Duskk

ASKER

Sorry. I failed to mention I had already tried that, and I just tried it again. It doesn't work. This is what I have:

td
{
    margin: 0;
    padding: 0;
    border: 0;
    font-style: inherit;
    font-size: 100%;
    font-family: inherit;
    vertical-align: baseline;
    vertical-align: top;
    text-align: left;
    font-weight: normal;
}

.tdHome
{
        text-align: left;
    vertical-align: top !important;
    padding: 3px 3px 3px 3px !important;
}

Open in new window


Here is my table:
                    <table width="1075px" >
                        <tr>
                            <td valign="top" align="left" class="tdHome">
                                <div id="swishmenu">
                                    <uc:MenuPanelBar ID="MenuPanelBar" runat="server" />
                                    <asp:Label ID="lblError" runat="server"></asp:Label>
                                </div>
                            </td>
                            <td valign="top" align="left" width="100%"  class="tdHome">
                                <div class="swishtext">
                                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                                    </asp:ContentPlaceHolder>
                                </div>
                            </td>
                            <td valign="top" align="center" width="15"  class="tdHome">
                                <asp:Panel ID="panPrintablePage" runat="server">
                                    <uc:PrintablePageIcon ID="PrintablePageIcon" runat="server" />
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As I indicated. It simply is not working with my code.

It only works if I put those values in the "td" CSS, and then it applies to every table, not just the on table. My .tdHome class does not override or do anything. It's as though it doesn't exist. It only does with the "td" does.

Oh well. Thanks to everyone anyway.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, I did in my original example, and Ironhoofs explained that. Thanks both of you for the explanation. Sadly, it doesn't help my situation.

But in my next example, I indicated that I failed to mention that I had already tried .tdHome by itself, and I again demonstrated the example code I am using showing that I used class="tdHome" and the CSS.

So yes, I've tried what the final recommendations are, shown the source code, and it isn't working for me. So I don't know why mine is failing. It should work. That's what I had tried in the first place, but after trying everything else, failed to report that in my initial post.

Anyway, thanks all. Everything I have tried should work, but it is not. Frustrating. I'll close this out.
Styles will sometimes not be applied correctly because of errors in the HTML or CSS. Do you have a working URL where we could see the problem? If not, the full CSS en HTML (not the ASP.NET code) should be sufficient...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
found reason for problem.