472,992 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 2285
"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
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
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
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
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.