Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS - referencing another class

Status
Not open for further replies.

Safacto

Programmer
Feb 10, 2002
15
GB
Hi,

On my site, I have CSS sheets with a relatively large amount of classes in them. In a lot of the classes, the colours (for example) are the same.

Is there a way to "reference" another class to set the right colour?? Basically, so I only have to change one colour, and all the colours in the other classes will change. For example, something like:

.dark{color: black}

.maintext{color: .dark.color}

Hence, giving
.maintext{color: black}


Is there a way to do this, or some other method that I haven't considered?? There are too many pages to go through and set two classes to everything.

Cheers,
Richard.
 
Oh, I suppose I could use the "inherit" commands, but due to the way the site is structured, it may not work right.

If there's another way I'd be gratefull.

Richard.
 
What you could do is put all the stuff that is the same
(for example: colors, widths, heights, text-decoration)
in id's (you create them by using a # instead of a .).
Then you can call them by <sometag id=&quot;someid&quot; class=&quot;someclass&quot;> this works just fine for me!

I hope this helps, BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

&quot;<beer brand> is like making love in a cano...
it's <f-word + ing> close to water !!!&quot;
- Monty Python's Flying Circus, 1969/70
 
That's a good idea. The problem is, is that I want to use one colour for text colours on parts of the site, and for backgrounds on other parts.

Although what you suggest would probably help, it would get too complicated to go through every single page of the website adding ID tags where appropriate.

Is there any other way of doing this??

Cheers,
Richard.
 
Hi Richard,

Well what you could also try is this:
Give the component group a style (for example make the code
count for all buttons or textaera's)

You can do that like this:
input{background-color: black; color: lime;}
#button{border-color: red;}
#radio(border-color: blue;)

this goes for ALL inputs then, no matter what their type
is, except for textarea. So then you could you smaller
ID's and fewer tags.

I hope this helps,

BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

&quot;<beer brand> is like making love in a cano...
it's <f-word + ing> close to water !!!&quot;
- Monty Python's Flying Circus, 1969/70
 
Hiya,

I think that this is all getting too complicated. It was only to save me a bit of time in the future. The site works, it's just a couple of cut and paste jobs that I'd've saved.

Thanks anyway,

Richard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top