471,603 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Basic Questions about Ruleset Sequence

1. Does it make any different what sequence I use to specify my rulesets?
For instance, is there a problem with specifying the rules for "p.footer"
before I have specified the rule for "p" or if I specify "p" before "body"?

2. What happens if I have multiple rulesets for the same selector? For
instance, if I specify
p {font-size: large} on one line of my stylesheet and then (inadvertently)
as p {font-size: small} further down, will the CSS validate and, if it does,
which will take precedence: the earliest definition or the last definition?

--
Rhio
Oct 1 '07 #1
2 1490
rhino wrote:
>
Okay, sounds like I need to learn the rules behind cascading. It is not
apparently as simple as "the last definition wins". Can you point me to a
good reference or tutorial on the subject? Something that is in clear
English, if possible. I don't want to have to take a degree in advanced
mathematics before I can understand the rules.
<http://www.w3.org/TR/CSS21/cascade.html#cascade>

--
Gus
Oct 2 '07 #2
On 2 Oct, 06:49, "rhino" <No.offline.contact.ple...@anonymous.com>
wrote:
Okay, sounds like I need to learn the rules behind cascading. It is not
apparently as simple as "the last definition wins". Can you point me to a
good reference or tutorial on the subject?
The W3C site itself (CSS 2.1).

Pay attention very carefully early on to the definitions of terms like
"rule" and "block". Then watch the _scope_ of what you're calculating
specificity on (i.e. does it apply to a rule or a block?) - that's
probably the most common misunderstanding.

If you make the deliberate effort to actually read the spec, and write
some demonstration examples to check what you're learning, then you
can learn this stuff easily enough (in a few mugfuls of coffee). The
trouble is that few people bother to make any actual effort at all.

Oct 2 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Steven O. | last post: by
28 posts views Thread by Dave | last post: by
4 posts views Thread by Ramesh | last post: by
18 posts views Thread by Ann Scharpf via AccessMonster.com | last post: by
97 posts views Thread by Master Programmer | last post: by
23 posts views Thread by sophia.agnes | last post: by
77 posts views Thread by Hans Schneider | last post: by
10 posts views Thread by gouqizi.lvcha | last post: by
reply views Thread by leo001 | last post: by

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.