HighDots Forums  

Repetition within the same CSS

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Repetition within the same CSS in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Neko
 
Posts: n/a

Default Repetition within the same CSS - 07-25-2006 , 08:39 AM






Is it possible to set up 'variables' or a way to call a CSS class from
within a CSS class?

What I'm trying to do is to be able to regroup the same CSS information
at the same place. On a big site, you get many CSS entry that some
time, have parts of them that have all the same value. Ex.: Color or
Background-Color

..TitreRouge
{
font-size: 22px;
font-weight: bold;
color: #BA0000;
}

..ST_TitreRouge
{
font-size: 16px;
font-weight: bold;
color: #BA0000;
}

..ST_ST_TitreRouge
{
font-size: 12px;
font-weight: bold;
color: #BA0000;
}

Would be nice if someone could tell me a way to get a wat to regroup
the color and font-weight at the same localisation so it does not get
copy/pasted on all the CSS.

Thanks,
Neko


Reply With Quote
  #2  
Old   
Christian Kirsch
 
Posts: n/a

Default Re: Repetition within the same CSS - 07-25-2006 , 08:44 AM






Neko schrieb:
Quote:
Is it possible to set up 'variables' or a way to call a CSS class from
within a CSS class?

no

Quote:
What I'm trying to do is to be able to regroup the same CSS information
at the same place. On a big site, you get many CSS entry that some
time, have parts of them that have all the same value. Ex.: Color or
Background-Color

.TitreRouge
{
font-size: 22px;
font-weight: bold;
color: #BA0000;
}

.ST_TitreRouge
{
font-size: 16px;
font-weight: bold;
color: #BA0000;
}

.ST_ST_TitreRouge
{
font-size: 12px;
font-weight: bold;
color: #BA0000;
}

Would be nice if someone could tell me a way to get a wat to regroup
the color and font-weight at the same localisation so it does not get
copy/pasted on all the CSS.
you could use a 2nd class in your HTML-code like so
<h2 class="titre_default "TitreRouge">

and then in CSS
..titre {
font-weight: bold;
color: #BA0000;
}

..TitreRouge {
font-size: 22px;
}

Alternatively, you could define the same attributes for the HTML
attributes you use:

h1, h2, h3 {
font-weight: bold;
color: #BA0000;
}


However, specifying font sizes in pixels is considered bad by many
regulars in this group.


Reply With Quote
  #3  
Old   
Neko
 
Posts: n/a

Default Re: Repetition within the same CSS - 07-25-2006 , 08:50 AM



Allright, Thanks.
I hope there will be a way to do so implemented soon. Would really add
organisation in CSS


Reply With Quote
  #4  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: Repetition within the same CSS - 07-25-2006 , 09:56 AM



Neko wrote:
Quote:
Is it possible to set up 'variables' or a way to call a CSS class from
within a CSS class?

What I'm trying to do is to be able to regroup the same CSS information
at the same place. On a big site, you get many CSS entry that some
time, have parts of them that have all the same value. Ex.: Color or
Background-Color

.TitreRouge
{
font-size: 22px;
font-weight: bold;
color: #BA0000;
}
Don't call the class TitreRouge. What happens if the site is redesigned
and it's decided to make the titles a different color? You could keep
the name TitreRouge, but that would create confusion. If you have to
change the name of the class everywhere it appears just because the
style changes, then you've defeated one of the main reasons to use
styles. So, give it a name (such as Titre) that is related to the use of
the class and not to the style you happen to be assigning it at the moment.

Quote:
.ST_TitreRouge
{
font-size: 16px;
font-weight: bold;
color: #BA0000;
}

.ST_ST_TitreRouge
{
font-size: 12px;
font-weight: bold;
color: #BA0000;
}
Make Titre one class and ST and ST_ST another pair of classes. You can
assign more than one class to an HTML element.

..Titre
{
font-weight: bold;
color: #BA0000;
}

..Titre.ST { font-size: 16px; }

..Titre.ST_ST {font-size: 12px; }

<div class="Titre">...
<div class="Titre ST">...
<div class="Titre ST_ST">...


(And I haven't even addressed why you shouldn't defined font sizes in
pixels. See many, many threads in this newsgroup for that.)


Reply With Quote
  #5  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: Repetition within the same CSS - 07-25-2006 , 10:08 AM



Neko wrote:
Quote:
Allright, Thanks.
I hope there will be a way to do so implemented soon. Would really add
organisation in CSS
The approach Christian and I provided IS a way to do it, and it's
already implemented. Yes, it requires you to plan and organize your
class structure effectively--and that's the way it *should* work.

Think of it this way. You want a particular combination of both font
weight and color to apply to several different parts of your page that
will, at the same time, differ in one or more ways from each other in
appearance. If there's a reason why those different elements should
share those two particular properties, it's means that there's something
about those elements that ties them together conceptually. You should
determine what that concept is and encapsulate it in a common class. Any
of the ways in which those elements differ from each other should be
factored out and expressed separately in other classes. Then assign the
respective elements to the appropriate class or combination of classes.

Either that, or there *isn't* any reason why those different elements
share those two particular properties--they just happen to. In that
case, you could easily decide later to change the style of one or more
of those elements independently of the others. In that case, you're just
locking yourself in unnecessarily by clumping the two properties
together and applying them as a unit, because if you change your mind
later then you just have to undo everything.


Reply With Quote
  #6  
Old   
Kevin Scholl
 
Posts: n/a

Default Re: Repetition within the same CSS - 07-25-2006 , 10:40 PM



Neko wrote:
Quote:
Is it possible to set up 'variables' or a way to call a CSS class from
within a CSS class?

What I'm trying to do is to be able to regroup the same CSS information
at the same place. On a big site, you get many CSS entry that some
time, have parts of them that have all the same value. Ex.: Color or
Background-Color

.TitreRouge
{
font-size: 22px;
font-weight: bold;
color: #BA0000;
}

.ST_TitreRouge
{
font-size: 16px;
font-weight: bold;
color: #BA0000;
}

.ST_ST_TitreRouge
{
font-size: 12px;
font-weight: bold;
color: #BA0000;
}

Would be nice if someone could tell me a way to get a wat to regroup
the color and font-weight at the same localisation so it does not get
copy/pasted on all the CSS.
..TitreRouge,
..ST_TitreRouge,
..ST_ST_TitreRouge
{
font-size: 22px;
font-weight: bold;
color: #BA0000;
}

..ST_TitreRouge
{
font-size: 16px;
}

..ST_ST_TitreRouge
{
font-size: 12px;
}

The subsequent class-specific declarations override the "default" font
size, but share the weight and color. Also, as others mentioned, you
might reconsider the use of px for your font sizes.

HTH.

--

*** Remove the DELETE from my address to reply ***

================================================== ====
Kevin Scholl http://www.ksscholl.com/
kscholl (AT) comcast (DOT) DELETE.net
------------------------------------------------------
Information Architecture, Web Design and Development
------------------------------------------------------
We are the music makers, and we are the dreamers of
the dreams...
================================================== ====


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.