473,511 Members | 15,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cascade (whole selector or parts of selector) rules?

Dear CSS gurus,

My question regarding 'the cascade' is a simple one, but one that I haven't
heard anyone talk about before:

When cascading (for instance, when applying two linked stylesheets), does
the whole selector definition supercede and replace a previous one, or does
it go through the selector definition line by line (rule by rule) and only
supercede rules and attributes that are previously defined?

In other words, if you have the following in a permanant stylesheet (as
opposed to persistant or alternate):

div.nav {
text-align : center;
border-bottom: 1px solid #ffff00;
background: #ff4500;
font: bold 12px/normal Arial, Helvetica, sans-serif;
color: #ffffff;
}

and then the user switches to a stylesheet (chooses an alternate stylesheet)
that contains the following (and is defined in coding order after the
previous sheet):

div.nav {
text-align : left;
}

do you lose all of the other rules (color, border, etc.), or will you retain
them and the only thing that will get superceded will be the 'text-align'
attribute ('center' gets superceded by 'left')?

The reason I'm asking is because in my limited experience, and in IE6 at
least (haven't yet tested in Moz, etc.), it seems that the second "div.nav"
definition completely wipes out the first one, which forces me to have to
copy and paste quite a bit of redundant information from one stylesheet to
another.

I thought the whole point of the cascade was to look rule by rule and either
supercede or append rules into the document, not to supercede entire
definitions as a whole. Am I wrong?

-- Richard
Jul 20 '05 #1
6 2313
"Richard Barnet" <rb*****@csaNOSPAMreno.org> wrote in message
news:bf**********@nnrp.atgi.net...
"Richard Barnet" <rb*****@csaNOSPAMreno.org> wrote in message
news:bf**********@nnrp.atgi.net...
"...if you have the following in a persistant stylesheet (as opposed to
preferred or alternate):"


I think I may've stumbled across something... can you have more than one
*preferred* stylesheet in effect at once? Also, if a page loads both a
persistant sheet and a preferred sheet, does it ignore the preferred sheet
until you select it (either in browser menus or via javascript)?

-- Richard
Jul 20 '05 #2
"Richard Barnet" <rb*****@csaNOSPAMreno.org> wrote in message
news:bf**********@nnrp.atgi.net...

I think I may've stumbled across something... can you have more than one
*preferred* stylesheet in effect at once?


Actually I partially found an answer, at:

http://www.w3.org/TR/html401/present/styles.html
"If two or more LINK elements specify a preferred style sheet, the first one
takes precedence."

Isn't this a little counter-intuitive, however? Per the cascade, it's
usually the last of something that take effect, not the first...???

-- Richard


Jul 20 '05 #3
In article <bf**********@nnrp.atgi.net>, rb*****@csaNOSPAMreno.org
says...
....
When cascading (for instance, when applying two linked stylesheets), does
the whole selector definition supercede and replace a previous one, or does
it go through the selector definition line by line (rule by rule) and only
supercede rules and attributes that are previously defined?
The latter; the browser overrides rule-by-rule. One thing to watch out
for, however, is shorthand properties. eg 'background: blue;' overrides
background-attachment, background-image, etc.

Also, don't forget inheritance, which depends on the nesting of items in
the html (so 'body:font-family:sans-serif' should set the font of
everything contained within the body).

References:
http://www.w3.org/TR/REC-CSS2/cascade.html
http://www.w3.org/TR/REC-CSS2/colors...def-background
http://www.w3.org/TR/REC-CSS2/cascade.html#inheritance

....
The reason I'm asking is because in my limited experience, and in IE6 at
least (haven't yet tested in Moz, etc.), it seems that the second "div.nav"
definition completely wipes out the first one, which forces me to have to
copy and paste quite a bit of redundant information from one stylesheet to
another.


Shouldn't do. Example URL?
Jul 20 '05 #4
"Jacqui or (maybe) Pete" <po****@spamcop.net> wrote in message
news:MP************************@news.CIS.DFN.DE...
Yeah, I think it's pretty confusing. There are 'preferred',
'persistent', and 'alternate' stylesheets depending on the title and
rel. Note that two stylesheets can have the same title in which case
they should both apply. .... The idea behind this is that you have one preferred stylesheet and a few
alternate ones that the readers can select (which they can, given a
sufficiently advanced browser or a touch of javascript).


Upon further reading, the part that is really confusing is that there are
really only two types (not three): persistant and alternate. 'Preferred' is
a subtype of alternate (i.e., it *is* an alternate). The ListApart article
is misleading. The W3C recommendation is more clear. Since alternate
stylesheets are mutually exclusive, you can only have one (or one named
group of sheets) at a time. =(

This causes several problems for me, unless I'm just thinking about this all
wrong. I'm working on a site with 6 different sheets (2 persistant [one for
screen, one for print], 1 alternate for largefonts, and 3 alternates for
'skins'). I would like the largefonts sheet to work in conjunction with any
of the skins, but since they're all alternate sheets, I can apparently only
have one at a time. That sucks.

What should happen (at least what I want to happen) is that you come to the
site and get the 'normal' layout (the persistant sheet and skin #1
[preferred alternate] combined). If you're visually impaired, you could
ideally select "largefonts" and still keep skin #1. From there, you could
choose skin #2 or #3 while still keeping largefonts (the largefonts sheet
supercedes the persistant sheet for font sizes).

What's happening in reality, at least for now, is that if you choose
largefonts, you lose the skin, and/or vice versa.

Does anyone know a way around this? I've already thought about grouping
skins together with largefonts, but that multiplies the number of user
options that they have to wade through - (skin #1 normal, skin #1
largefonts, skin #2 normal, skin #2 largefonts, etc.)

It would be nice to just present the user with either normal or largefonts,
and their choice of skin. In other words, it would be nice if the W3C would
take away the "mutually exclusive" rule, and let you stack alternate sheet
upon alternate sheet ad infinitum (or ad nauseum). =)

-- Richard
Jul 20 '05 #5
"Jacqui or (maybe) Pete" <po****@spamcop.net> wrote in message
news:MP************************@news.CIS.DFN.DE...
The reason I'm asking is because in my limited experience, and in IE6 at
least (haven't yet tested in Moz, etc.), it seems that the second "div.nav" definition completely wipes out the first one, which forces me to have to copy and paste quite a bit of redundant information from one stylesheet to another.


Shouldn't do. Example URL?


Actually, I misread the symptoms. It turns out it wasn't the cascade at
all, it was the "mutually exclusive" rule for alternate stylesheets (see our
other sub-thread, above).

-- Richard
Jul 20 '05 #6
"Richard Barnet" <rb*****@csaNOSPAMreno.org> wrote in message
news:bf**********@nnrp.atgi.net...
It would be nice to just present the user with either normal or largefonts, and their choice of skin. In other words, it would be nice if the W3C would take away the "mutually exclusive" rule, and let you stack alternate sheet
upon alternate sheet ad infinitum (or ad nauseum). =)


I'm hereby moving this sub-thread to the more aptly named thread "Multiple
linked stylesheets", since this is really what is happening to my site, not
the cascade problem I originally thought it was. Thanks.

-- Richard
Jul 20 '05 #7

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

Similar topics

1
2108
by: John Rowe | last post by:
I run the web site for a University department. A few of my authors will carefully write: <h3>Title</h3> <p>Some text here.</p> <p>Second paragraph.</p> Most of us can't be bothered(!): ...
2
1591
by: Paul Wake | last post by:
Why does the first thing work, but the second doesn't? The attempt is to style, for printing purposes, an online document so that when printed it will look like the original article. The original...
33
4241
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
5
3170
by: Giggle Girl | last post by:
Is there a way to prevent properties (specifically, height and background color) from being "inherited" by nested tables? Something similar (but sort of opposite to) !important, like...
4
6388
by: Blue Apricot | last post by:
How can I prevent certain Class properties from cascading from a parent table to its children? Specifically, I have a table that acts as a container (I call it class="page"), with a certain...
3
1909
by: JakDaniel | last post by:
is it possible, create a selector as alias of another selector... (maybe) in another stylesheet file? ex: html page .... <link rel="stylesheet" type="text/css" href="style1.css" /> <link...
3
2133
by: blakerrr | last post by:
Hello World! I'm a rookie with access and my green skin needs a little help. I have two tables, one called BOM and one called Junction. BOM contains parts and assemblies and subassemblies info and...
0
1647
by: Cirene | last post by:
Can you assist me with this database problem? I have 4 tables in my db.... Table1 (key: Table1Id) Table2 (key: Table2Id) Table3 (key: Table3Id) Table 4 has these fields: key: Table4Id...
41
2560
by: Stan Brown | last post by:
As usual, it looks right in Firefox 3 but not in IE6. See http://www.tc3.edu/instruct/sbrown/nicholls/indexgood.htm for the desired behavior -- when you hover over the second or third main menu...
0
7137
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
7349
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,...
0
7417
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...
1
5063
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...
0
3219
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...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
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 ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
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...

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.