473,396 Members | 1,849 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,396 software developers and data experts.

Combining Styles

Hi All

If I had the following 3 style in a CSS file
<style>
.bordered {border: red thin soldid;}
.warning {background-color: #900;}
.box {padding: 5%; text-align:justify;}
</style>
Then in my html page I can do somthing like this:
<div class="box warning bordered">This is a warning.</div>

is there a way to "combined" the 3 styles into a 4th one eg:
<style>
.mywarning {box; warning; bordered}
</style>

so I can do things like this:
<div class="mywarning">This is a warning.</div>

and also still use the 3 original styles like:
<div class="bordered">a border around me</div>
Thanks for any help/tips

Al.
Jul 20 '05 #1
6 6835
In article <vc********************************@4ax.com> in
comp.infosystems.www.authoring.stylesheets, Harag
<ha***@softGETRIDOFCAPLETTERShome.net> wrote:
is there a way to "combined" the 3 styles into a 4th one eg:
<style>
.mywarning {box; warning; bordered}
</style>


No. There is no way in plain CSS to make a new class include the
properties of existing classes. Some sort of preprocessor could
probably do the job.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #2
*Harag* <ha***@softGETRIDOFCAPLETTERShome.net>:

.bordered {border: red thin soldid;}
.warning {background-color: #900;}
.box {padding: 5%; text-align:justify;}

is there a way to "combined" the 3 styles into a 4th one


.mywarning, .bordered {border: red thin soldid;}
.mywarning, .warning {background-color: #900;}
.mywarning, .box {padding: 5%; text-align:justify;}

Virtually every CSS tutorial would have told you that in its "Selectors"
chapter.

--
Alcohol didn't cause the high crime rates of the '20s and '30s, Prohibition did.
And drugs do not cause today's alarming crime rates, but drug prohibition does.
(US District Judge James C. Paine, November 1991)
Jul 20 '05 #3
In article <bo**********@ariadne.rz.tu-clausthal.de> in
comp.infosystems.www.authoring.stylesheets, Christoph Paeper
<cr***********@gmx.net> wrote:
.mywarning, .bordered {border: red thin soldid;}


Shouldn't that be "sordid"? :-)

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #4
I'm dont think you quite understand what I was after.

I don't want to redefine "bordered, warning & Box" I just want to use
them in one class.

if I have in one css fiile "FX.css"
..Bordered {border: red thin solid;}
..bgCCC {background-color: #CCC;}
..bg00C {background-color: #00C;}
..bg0C0 {background-color: #0C0;}
..bgC00 {background-color: #C00;}
..Box {padding: 5%; text-align:justify;}

I want to beable to define things like
..Warning {Bordered; bgC00; Box;)
..Note {bg00C; Box}

then in my html i can do:
<div class="Warning">this is a warning</div>

instead of:
<div class="Box Bordered bgC00">this is a warning</div>

if I want to change the background color of warnings throughout the
page then I can just edit the ".Warning {Bordered, bgC00, Box)" and
change it to ".Warning {Bordered, bgCCC, Box)" rather than edit every
DIV on the page where the warning is used.

Hope this is made clearer.

Al.
On Sun, 2 Nov 2003 02:26:41 +0100, Christoph Paeper
<cr***********@gmx.net> wrote:
*Harag* <ha***@softGETRIDOFCAPLETTERShome.net>:

.bordered {border: red thin soldid;}
.warning {background-color: #900;}
.box {padding: 5%; text-align:justify;}

is there a way to "combined" the 3 styles into a 4th one


.mywarning, .bordered {border: red thin soldid;}
.mywarning, .warning {background-color: #900;}
.mywarning, .box {padding: 5%; text-align:justify;}

Virtually every CSS tutorial would have told you that in its "Selectors"
chapter.


Jul 20 '05 #5
In article Harag wrote:
I'm dont think you quite understand what I was after.

I don't want to redefine "bordered, warning & Box" I just want to use
them in one class.

if I have in one css fiile "FX.css"
.Bordered {border: red thin solid;}
.bgCCC {background-color: #CCC;}
.bg00C {background-color: #00C;}
.bg0C0 {background-color: #0C0;}
.bgC00 {background-color: #C00;}
.Box {padding: 5%; text-align:justify;}

I want to beable to define things like
.Warning {Bordered; bgC00; Box;)
.Note {bg00C; Box}
That is not possible using CSS.
then in my html i can do:
<div class="Warning">this is a warning</div>

instead of:
<div class="Box Bordered bgC00">this is a warning</div>

if I want to change the background color of warnings throughout the
page then I can just edit the ".Warning {Bordered, bgC00, Box)" and
change it to ".Warning {Bordered, bgCCC, Box)" rather than edit every
DIV on the page where the warning is used.


You might want to use some server side language.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #6
*Harag* <ha***@softGETRIDOFCAPLETTERShome.net>:

I'm dont think you quite understand what I was after.
Be assured I did.
I don't want to redefine "bordered, warning & Box" I just want to use
them in one class.


Because that is not possible the way you want it, I showed you the way it is
possible with CSS. The result is virtually the same.

--
"Opportunity is missed by most people
because it is dressed in overalls and looks like work."
Thomas Alva Edison
Jul 20 '05 #7

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

Similar topics

0
by: Quinton | last post by:
I'm running a website that uses CSS to format the text and a CGI program Coranto that icludes news updates via SSI. My problem is that some parts of the CSS don't seem to take effect on the...
2
by: Chris Mullins | last post by:
I've spent a bit of time over the last year trying to implement RFC 3454 (Preparation of Internationalized Strings, aka 'StringPrep'). This RFC is also a dependency for RFC 3491...
7
by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following...
12
by: dan.vendel | last post by:
Hi, I know nothing about javascript, but quite a lot about regulat html and CSS. Have bumped into a problem that people in this fine congregation perhaps can help me with. I'm making a...
3
by: JezB | last post by:
What's the generally accepted approach for using Styles and Stylesheets in a web application based on .aspx files, Web Controls, User Controls, and code-behind modules (c# in my case)? Most style...
3
by: spolsky | last post by:
hi, it is possible to apply multiple styles as shown in the following example. <STYLE TYPE="text/css"><!-- BODY { background-color:salmon; } P { margin-left:20px; } .clsCode {...
2
by: TonyV | last post by:
Okay, this is driving me nuts, and while I'm still researching, I'm hoping someone here can help. I'm trying to create a simple page with a navigation menu on the left side of the main content...
4
by: splounx | last post by:
Hi there, I am a relative CSS & JavaScript novice and I have a particular problem that is beyond my level of knowledge so I thought I'd tap the collective wisdom of this group. I would like...
5
by: Tristan Miller | last post by:
Greetings. Is it possible using HTML and CSS to represent a combining diacritical mark in a different style from the letter it modifies? For example, say I want to render Å‘ (Latin small letter...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.