473,659 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_TitreRo uge
{
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 1704
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_TitreRou ge
{
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_de fault "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_TitreRou ge
{
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_TitreRou ge
{
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_TitreRo uge
{
font-size: 22px;
font-weight: bold;
color: #BA0000;
}

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

..ST_ST_TitreRo uge
{
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
1943
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 impossible, yet I ask anyway: Is it possible to eliminate the second (third, fourth, fifth, etc.) occurrence of any given word when its presence in the document is being scored, yet kept in the equation for modifications to the score when proximity...
2
1692
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 num=this.GetNumber(((Button)sender).Name); //check if there is a TextBox with same number of the sender after
6
34224
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 (with nested For … Next statements) and minimize the number of output statements. * *** ***** ******* ********* ******* *****
4
2991
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 following output would be ok a,b,c,a,d,c or a,c,d,a,d,a but the following would not; a,b,c,c, or a,b,b,c, etc... I hope that makes sense. If it helps to understand what I'm trying to do I have the following python code.
4
5400
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 worm is moving toward an apple. each time it moves, the worm cuts the distance between itself and the apple by its own body lenght until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body lenth of the...
1
1875
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 have to click on each one. My problem is that I have a date parameter for each one and am tired of having to type the date each time. I will be using the same date range for each qurey so it there a way to just enter the date once and then it will...
5
3053
by: NATHAN1511 | last post by:
How To Write A Program By Using Repetition Structure As Show Below: 1 12 123 1234 12345
15
3074
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 digit 1 time, 2nd digit 2 times, 3rd digit 3 times and so forth... I cannot get the last bit working, what bit of code can i use for the repetition part? many thanks
3
1354
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 wierd..they r not same.. i used "for" repetition..
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.