/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Applying TD style to a specific table class

I have a set of CSS elements for all tables across my web app like so:

[code=php]
TD, P
{
FONT-SIZE: 8pt;
COLOR: #000;
FONT-FAMILY: Arial, Helvetica, sans serif;
}
TH {
border-top: 1px solid #ccc;
border: 1px solid #ccc;
border-bottom: 1px solid #ccc;
color: #efefef;
background: #011d4b url(../images/th_background.gif) repeat-x;
text-align: center;
font-size: 85%;
}
[/code]

But I have a specific class for data output tables which contains additional styling (for use with a .js alternating row color), like so:

[code=php]
.dataTable
{
margin-top: 0.5em;
border: 1px solid #DDD;
border-collapse: collapse;
border-spacing: 1px;
}
[/code]

I need to add additional TD elements to just tables using the dataTable class, so that I can have borders between the columns.

Was trying something like this, but I can’t get the syntax to work:

[code=php]
td.dataTable
{
border: 1px dotted #DDD;
}
[/code]

Hoping someone can help me with what should be a simple thing. Thanks.

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Jun 11.2008 — <i>
</i>td.dataTable
{
border: 1px dotted #DDD !important;
}

What exactly isn't working?
Copy linkTweet thisAlerts:
@chrisHHRauthorJun 11.2008 — td.dataTable

{

border: 1px dotted #DDD !important;

}[/QUOTE]


That's not working.

My goal is to create a border for all cells only in tables with class="dataTable". I don't want TD borders anywhere else in any other tables.
Copy linkTweet thisAlerts:
@gil_davisJun 11.2008 — td.dataTable[/quote]would apply the style to a TD with a class named "dataTable". If you want a TD inside the TABLE with the class "dataTable", you would need to declare this instead:
.dataTable td
Copy linkTweet thisAlerts:
@chrisHHRauthorJun 11.2008 — .dataTable td[/QUOTE]

Perfect, thank you. That makes sense. datatable.td would have required the class be called inside each td tag.
×

Success!

Help @chrisHHR spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...