By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,447 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,447 IT Pros & Developers. It's quick & easy.

Multiple CSS with same class names on same page?

P: n/a

My goal is to have two items, both with the same class and on the same
page, display differently through some external code.

For example:

<div class="green">
<p class="title">Services</p>
<p class="content">Help your business reach success</p>
<div class="gray">
<p class="title">Manual</p>
<p class="content">View your user manual here</p>

So, "Services" will show up green, while "Manual" will show up gray,
even though they both are under the same class p.title.

Is there a way to accomplish this?? I have always done it as
p.greentitle {color: green;}
p.graytitle {color:gray; }

But now the requirement is that they both should have the same styling,
that is controlled externally. I have no idea how this can be

Please help!! Thanks a bunch!


Jan 24 '07 #1
Share this Question
Share on Google+
2 Replies

P: n/a
ji******* wrote:
Is there a way to accomplish this?? p.title
color: green;

div.gray p.title
color: gray;

What if you decide to change the colors later? Your class names won't
make much sense then.

Here's some more information on selectors from the CSS2 Specification:
Jan 24 '07 #2

P: n/a
Thank you very much Sir, that is wonderful music to my ears!!

The business requirement most likely requires some DIVs to stand out,
and some others not, based on some other criteria unbeknowns to me, but
this solution will resolve the issue for sure!

Thanks again!


Jan 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.