473,729 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cascading several classes at once

I try to combine properties of several classes. This is done by assigning a
space separated list of class definitions to an element. However, IE shows a
kind of preference when choosing the right property which I think is
probably wrong. Here's what it does:

If two classes are defined in a stylesheet providing the same property, and
if these two classes are assigned to one single element, the preference
which class's property is used is *not* set by the elements class definition
but by the sequence of class definitions in the stylesheet.

I think this takes away much flexibility. Any opinion?

Here's an example:

-----------------
..c1
{color: black;
}

..c2
{color: red;
}
-----------------
<span class="c1 c2">This is shown red.</span>
<span class="c2 c1">This is also shown red.</span>
-----------------
To my opionion it should be:
-----------------
<span class="c1 c2">This is shown red.</span>
<span class="c2 c1">This is shown black.</span>
-----------------
Jul 20 '05 #1
31 6818
Axel Dahmen wrote:
I try to combine properties of several classes. This is done by
assigning a space separated list of class definitions to an element.
However, IE shows a kind of preference when choosing the right
property which I think is probably wrong. Here's what it does:


IE is broken in regards to multiple classes assigned to a single
element!

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #2
"Axel Dahmen" <No****@NoOneKn ows.de> wrote:
I try to combine properties of several classes. This is done by assigning a
space separated list of class definitions to an element. However, IE shows a
kind of preference when choosing the right property which I think is
probably wrong. Here's what it does:

If two classes are defined in a stylesheet providing the same property, and
if these two classes are assigned to one single element, the preference
which class's property is used is *not* set by the elements class definition
but by the sequence of class definitions in the stylesheet.


That's correct behaviour.

Check out
http://www.w3.org/TR/CSS2/cascade.html#specificity
and
http://www.w3.org/TR/html401/struct/...tml#adef-class

There's nothing there to imply that multiple classes specified for a
single element have anything other than equal specificity. Thus the
standard CSS specificity rules apply and the stylesheet determines
which applies.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #3
Do you think it might be worth proposing such behaviour to the CSS group?
---------------------------
"Steve Pugh" <st***@pugh.net > schrieb im Newsbeitrag
news:40******** *************** *********@4ax.c om...
"Axel Dahmen" <No****@NoOneKn ows.de> wrote:
I try to combine properties of several classes. This is done by assigning aspace separated list of class definitions to an element. However, IE shows akind of preference when choosing the right property which I think is
probably wrong. Here's what it does:

If two classes are defined in a stylesheet providing the same property, andif these two classes are assigned to one single element, the preference
which class's property is used is *not* set by the elements class definitionbut by the sequence of class definitions in the stylesheet.


That's correct behaviour.

Check out
http://www.w3.org/TR/CSS2/cascade.html#specificity
and
http://www.w3.org/TR/html401/struct/...tml#adef-class

There's nothing there to imply that multiple classes specified for a
single element have anything other than equal specificity. Thus the
standard CSS specificity rules apply and the stylesheet determines
which applies.

Steve


Jul 20 '05 #4
"Axel Dahmen" <No****@NoOneKn ows.de> wrote:
"Steve Pugh" <st***@pugh.net > schrieb im Newsbeitrag
news:40******* *************** **********@4ax. com...
"Axel Dahmen" <No****@NoOneKn ows.de> wrote:
If two classes are defined in a stylesheet providing the same property,
and if these two classes are assigned to one single element, the
preference which class's property is used is *not* set by the elements
class definition but by the sequence of class definitions in the stylesheet.
That's correct behaviour.

Check out
http://www.w3.org/TR/CSS2/cascade.html#specificity
and
http://www.w3.org/TR/html401/struct/...tml#adef-class

There's nothing there to imply that multiple classes specified for a
single element have anything other than equal specificity. Thus the
standard CSS specificity rules apply and the stylesheet determines
which applies.


Top posting fixed. Don't do it again.
Do you think it might be worth proposing such behaviour to the CSS group?


No. It would be tricky to combine with the current specificity rules
and would cause a number of existing pages to suddently change in
appearance when/if browsers supported it.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #5
Philipp Lenssen wrote:
I try to combine properties of several classes. This is done by
assigning a space separated list of class definitions to an element.
However, IE shows a kind of preference when choosing the right
property which I think is probably wrong. Here's what it does:


IE is broken in regards to multiple classes assigned to a single
element!


Which IE? There are many versions, on 2 platforms. FWIW, they seem
to work in MSIE 5.0/Win2k.

--
Brian
follow the directions in my address to email me

Jul 20 '05 #6
> Top posting fixed. Don't do it again.

???

Do you think it might be worth proposing such behaviour to the CSS group?


No. It would be tricky to combine with the current specificity rules
and would cause a number of existing pages to suddently change in
appearance when/if browsers supported it.


Hmmm... good news: There is no tricky part, it's simply "last serves first".
As multiple class references can only appear at one place (in the class
attribute), specificity rules don't apply. Anything more specific overrides
the class definition anyway.

BTW: Specificity rules have changed from CSS1 to CSS2 already. The new
definition would just put an undefined state into definition. As no one can
actually use this feature by now (is undefined behaviour), there are no web
pages to break.
Jul 20 '05 #7
In article <bn**********@o nline.de> in
comp.infosystem s.www.authoring.stylesheets, Axel Dahmen
<No****@NoOneKn ows.de> wrote:
(quoting Steve Pugh, without attribution)
Top posting fixed. Don't do it again.


???


http://oakroadsystems.com/genl/unice.htm
talks about top posting (which you did but shouldn't do) and
attributions (which you didn't but should do).

Top posting is also known as "posting upside down".

--
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 #8
*Axel Dahmen* <No****@NoOneKn ows.de>:

If two classes are defined in a stylesheet providing the same property, and
if these two classes are assigned to one single element, the preference
which class's property is used is *not* set by the elements class definition
but by the sequence of class definitions in the stylesheet.
Correct, that's a matter of the cascade and specifity in CSS.
.c1 {color: black;}
.c2 {color: red;}

<span class="c1 c2">This is shown red.</span>
<span class="c2 c1">This is also shown red.</span>


Sure, a space separated list is a list of equals in HTML. Anything else is
the job of CSS.

Why do you give both classes on both elements anyway? There's surely a
better way in almost any situation you would want to do that.

--
The Hitchhiker's Guide to the Galaxy:
"The Universe, as has been observed before, is an unsettlingly big place,
a fact which for the sake of a quiet life most people tend to ignore."
Jul 20 '05 #9
"Axel Dahmen" <No****@NoOneKn ows.de> wrote:
BTW: Specificity rules have changed from CSS1 to CSS2 already.
Only in so far as that the CSS2 specs refer to things (attribute
selectors and pseudo-classes) that didn't exist in CSS1

CSS1:

To find the specificity,
count the number of ID attributes in the selector (a),
the number of CLASS attributes in the selector (b),
and the number of tag names in the selector (c).
Concatenating the three numbers (in a number system with a large base)
gives the specificity.

CSS2:

A selector's specificity is calculated as follows:
count the number of ID attributes in the selector (= a)
count the number of other attributes and pseudo-classes in the
selector (= b)
count the number of element names in the selector (= c)
ignore pseudo-elements.
Concatenating the three numbers a-b-c (in a number system with a large
base) gives the specificity.

Perhaps you're getting confused with the change in cascade order with
regards to !important styles?
The new
definition would just put an undefined state into definition.
It's not undefined at all. I gave you the definition earlier - the
standard CSS rules apply - if both classes are otherwise equal (i.e.
if the stylesheet has them as .foo and .bar and not as .foo and
p.bar) then the last specified takes precedence. What's not undefined
about that?
As no one can
actually use this feature by now (is undefined behaviour), there are no web
pages to break.


I use multiple classes on some of my web pages, so yes it would change
existing web sites.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #10

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

Similar topics

7
1520
by: CheGueVerra | last post by:
First of all Hello all you css freak. geeks and gurus. I just started using css for some web pages I had to do at work and I'im testing some stuff at home to understand more. Now, I wanted to understand better of how cascading works. in my .css file I created this tr#noLine{ border-top-width:0; border-left-width:0;
0
1319
by: Scott McChesney | last post by:
I'm writing a Windows application for a client, and I've run into a problem I don't know how to solve. The UI is relatively simple - a listbox on the left (in a panel), and a third-party tab control on the right (also in a panel). The usual splitter bar, and all that good stuff. The tab control is set up to deal with drag/drop events, so that users can drag an item from the listbox over the tab control and have the tab control respond...
2
2053
by: Herb Stull | last post by:
I'm trying to give users a choice of the visual interface used in my ASP.NET application using Cascading Style Sheets. Ideally I'd like to offer them several choices for backgrounds, fonts, etc. for the screens and controls and let them make a choice. Once they choose, all screens and controls will display using the guidelines from the style sheet selected. I've figured out how to add a class to the style sheet for the different...
1
1121
by: Fred Nelson | last post by:
Hi: I have a VB.NET web application that has been running just fine for several months without any cascading style sheets. Suddenly several users have had problems with the layout of the screen. In particular some text boxes are getting too large and covering buttons and therefore preventing them from being pushed. It appears that some other application - or perhaps a plug-in - (probably an unwanted plug-in) changes the
4
2316
by: Fred Nelson | last post by:
Hi: I have a VB.NET web application that has been running just fine for several months without any cascading style sheets. Suddenly several users have had problems with the layout of the screen. In particular some text boxes are getting too large and covering buttons and therefore preventing them from being pushed. It appears that some other application - or perhaps a plug-in - changes the default browser settings and then causes...
2
2048
by: tschwartz | last post by:
I have an xml document in which elements are hierarchically related to eachother conceptually. Unfortunately, the hierarchical relationship is not modelled in the schema (i.e., the elements are "flattened" in the document". I have a case in which I want to remove a high level element using xslt and want all the related lower-level elements to be removed as well. Is there an easy way to do this in a template? For example, imagine a...
7
1814
by: Green Xenon [Radium] | last post by:
Cascading Style Sheet is such a hazard to your privacy. It allows others on the internet to see your monitor and files. It allows them to copy images on your monitor to their computers. It also allows them to copy files from your computer to their computers. It is dangerous. Avoid at all costs. CSS isn't stored in the victim's computer. Instead it is stored in the perpetrator's computer. What it does is it reads everything on the...
7
2545
kcdoell
by: kcdoell | last post by:
I have three tables: One for the Division location: tblDivision DivisionID = Autonumber DivisionName = Text One for the Working Region: tblWrkRegion
0
8927
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
8764
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
9428
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...
0
9289
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9210
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,...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4798
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3242
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
2694
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.