473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Repetition within the same CSS

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

Jul 25 '06 #1
5 1691
Neko schrieb:
Is it possible to set up 'variables' or a way to call a CSS class from
within a CSS class?
no
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.
Jul 25 '06 #2
Allright, Thanks.
I hope there will be a way to do so implemented soon. Would really add
organisation in CSS

Jul 25 '06 #3
Neko wrote:
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.
>
.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.)
Jul 25 '06 #4
Neko wrote:
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.
Jul 25 '06 #5
Neko wrote:
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/
ks*****@comcast.DELETE.net
------------------------------------------------------
Information Architecture, Web Design and Development
------------------------------------------------------
We are the music makers, and we are the dreamers of
the dreams...
================================================== ====
Jul 26 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Gamache | last post by:
For my particular case, word repetition shouldn't be relevant in determining the rank of a document. If I strip() the vector, I loose what relevance proximity and weight add to the rank. It seems...
2
by: Bart | last post by:
Dear all, I have a problem that I cannot understand the reason of. My code is private void ButtDetl_Click(object sender, System.EventArgs e) { // give an information of the sender int...
6
by: udhas | last post by:
Write a program that prints the following diamond shape. You may use output statements that print a single asterisk (*), a single space or a single carriage return. Maximize your use of repetition...
4
by: mj.clift | last post by:
Hi All, I need to be able to choose a random string from an array. That is easy enough, but I want to restrict the repetition of that string until one or two other choices have been made. So the...
4
by: XpatienceX | last post by:
Hi, Can someone help me with this assignment, I am confused of what is needed to be done here. I am suposed to design a program that models a worm's behavior in the following scenario: A...
1
by: bearuser | last post by:
I have a question that has been stumping me for a week. I have set up several basic queries that I need to run quickly. I then created a macro to run each of the make table queries so that I do not...
5
by: NATHAN1511 | last post by:
How To Write A Program By Using Repetition Structure As Show Below: 1 12 123 1234 12345
15
by: Beany | last post by:
Hi All, i need help with the following: i need to write a simple program that asks the user to input a number (minimum of 3 digits), which i seperate into individual digits and print the 1st...
3
by: anizatie | last post by:
if i wanna do some programming lets say... i hv a=a+3*a*(1.0^-10) how to generate the answer if a=(1.0^-10) ive done but wen i compared the answer using calculator..the answer is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.