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

css2 -- pattern-matching..

I'm trying to learn CSS2, find some aspects of it quite confusing..

here, http://www.w3.org/TR/REC-CSS2/selector.html#q1 I see this:

E F : Matches any F element that is a descendant of an E element.
Descendant selectors
E > F : Matches any F element that is a child of an element
E. Child selectors

please, what is difference between a descendant and a child element..

thank you.
Jun 9 '06 #1
4 1909
maya wrote:
I'm trying to learn CSS2, find some aspects of it quite confusing..

here, http://www.w3.org/TR/REC-CSS2/selector.html#q1 I see this:

E F : Matches any F element that is a descendant of an E element.
Descendant selectors
E > F : Matches any F element that is a child of an element
E. Child selectors

please, what is difference between a descendant and a child element..

thank you.


Your child is your child. Your descendant can be your child, your
grandchild, your great-grandchild, etc.
Jun 9 '06 #2
Harlan Messinger wrote:
maya wrote:
I'm trying to learn CSS2, find some aspects of it quite confusing..

here, http://www.w3.org/TR/REC-CSS2/selector.html#q1 I see this:

E F : Matches any F element that is a descendant of an E element.
Descendant selectors
E > F : Matches any F element that is a child of an element
E. Child selectors

please, what is difference between a descendant and a child element..

thank you.

Your child is your child. Your descendant can be your child, your
grandchild, your great-grandchild, etc.


ok, thank you very much.. I had thought maybe they were different
relationships..

Jun 9 '06 #3
maya wrote:
Harlan Messinger wrote:
maya wrote:
I'm trying to learn CSS2, find some aspects of it quite confusing..

here, http://www.w3.org/TR/REC-CSS2/selector.html#q1 I see this:

E F : Matches any F element that is a descendant of an E element.
Descendant selectors
E > F : Matches any F element that is a child of an element
E. Child selectors

please, what is difference between a descendant and a child element..

thank you.


Your child is your child. Your descendant can be your child, your
grandchild, your great-grandchild, etc.


ok, thank you very much.. I had thought maybe they were different
relationships..


Umm - you're not paying attention. They ARE different relationships.

A child is a descendant, yes. But although a descendant can be a child,
a descendant can also be a grandchild, etc.

To put it back in CSS terms - (using your case above) assume the style:

div.E div.F { background-color: red; }

If you have:

<div class="E"> (filler)
<div class="whatever"> (filler)
<div class="F">Stuff here</div>
</div>
</div>

<div class="E"> (filler)
<div class="F">Stuff here</div>
</div>

both class "F" divs would have a red background.

BUT if you defined the style as:
div.E > div.F { background-color: red; }

ONLY the second one would have a red background - since the first one is
a descendant, but NOT a CHILD of "E".

--
"The most convoluted explanation that fits all the available and made-up
facts is the most likely to be believed by conspiracy theorists"
Jun 10 '06 #4
Tony <to****@dslextreme.WHATISTHIS.com> scripsit:
A child is a descendant, yes. But although a descendant can be a
child, a descendant can also be a grandchild, etc.
These metaphoric names - which derive from the common information technology
jargon - are rather unfortunate. A father or a mother does not contain their
children and other descendants.

We cannot change these misleading terms, but it helps to translate them
(mentally and in teaching) to more suitable expressions. A "child" is a
(direct) subelement, whereas a "descendant" is an indirect subelement, i.e.
a subelement or a subelement of a subelement etc. There is nothing
comparable to begetting a child or giving birth to a child or raising a
child. ("Inheritance" - probably the most often and most seriously
misunderstood basic concept of CSS - means that a subelement copies a
property value from its enclosing element if does not get a value for the
property from any style sheet directly. So the word "inherit" is hardly a
good metaphor either.)
To put it back in CSS terms - (using your case above) assume the
style:
div.E div.F { background-color: red; }
That's a bad example; setting background-color without setting color (or
background-image) is bad practice. It's common practice, and therefore it's
particularly bad style in an example. It's not "just an example". People
learn by example. If your text contradicts with your examples, people
understand, believe, and remember the examples and ignore the texts. With a
bit exaggeration (well, maybe a little more than a bit), one can say that in
explaining matters like CSS, or markup, or programming, examples are the
real thing, and the text is there just to fill the pages and perhaps to be
consulted if an example is not quite crystal clear.
both class "F" divs would have a red background.
Assuming that no other style sheets are involved, that is.
BUT if you defined the style as:
div.E > div.F { background-color: red; }

ONLY the second one would have a red background - since the first one
is a descendant, but NOT a CHILD of "E".
Wouldn't it be simpler to say just that
..E .F matches any class "F" element that is directly or indirectly a
subelement of a class "E" element, whereas
..E > .F matches any class "F" element that is a direct subelement of a class
"E" element?

I'm afraid it needs to be mentioned that direct subelement selectors like .E .F are generally not useful in CSS authoring for the WWW at present or in

the near future, since they are not supported by IE 6. Of course, if you are
prepared to having anything applied to such a selector ignored in most
browsing situations, then it's just fine.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jun 10 '06 #5

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

Similar topics

4
by: Neil Zanella | last post by:
Hello, I would like to know what the major enhancements of CSS2 over CSS1 are and whether CSS2 support is any better these days than it was a few years ago. In particular, do most browsers fully...
12
by: Michael Winter | last post by:
Is it possible to test for CSS level 2 support, preferably using just CSS2? For example, the following could alert the user that their browser doesn't support CSS1 or 2. Is there an equivalent for...
6
by: Patrick | last post by:
Hi I am a newbie struggling a little with css.It is hard to get it right in all browsers, so i decided to read the CSS2 specification on the w3 site. What is the following from the CSS2...
20
by: Karl Smith | last post by:
I heard a rumour that Opera succeeded where none have before, and implemented the tables described in HTML4 and CSS2. So I thought I'd try it out with the well known Periodic Table. ...
14
by: Michael Bulatovich | last post by:
Has anyone got a good link to a concise discussion of where things now stand regarding these two? e.g. What browsers are compliant with one or the other? What the adoption rate is of these...
2
by: Jan Roland Eriksson | last post by:
The following URL... <http://www.w3.org/TR/CSS21/> ....has had the following text in it for a considerable time now. "This is a W3C Candidate Recommendation, which means the specification...
2
by: Xah Lee | last post by:
what's new in CSS2? http://xahlee.org/js/css2.html Xah xah@xahlee.org ∑ http://xahlee.org/
2
by: David E. Ross | last post by:
A new working draft of the CSS2.1 specification was published on-line on 11 April. Does anyone know what changed since the previous (13 June 2005) working draft? -- David E. Ross...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
1
by: Jean Pierre Daviau | last post by:
Hi, I am looking for a pdf version of CSS2.1 Specification Thanks -- Jean Pierre Daviau
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.