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 specification:
"Quote starts":
5.6 Child selectors
A child selector matches when an element is the child [p. 30] of some
element. A
child selector is made up of two or more selectors separated by ">".
Example(s):
The following rule sets the style of all P elements that are children
of BODY:
BODY > P { line-height: 1.3 } /* OP note: What is this line?*/
Example(s):
The following example combines descendant selectors and child
selectors:
DIV OL>LI P
It matches a P element that is a descendant of an LI; the LI element
must be
the child of an OL element; the OL element must be a descendant of a
DIV.
Notice that the optional whitespace around the ">" combinator has been
left out.
For information on selecting the first child of an element, please see
the
section on the :first-child [p. 62] pseudo-class below.
"Quote ends":
That line with the ">" sign gets me.I have tried several things in my
notepad editor to test it but it doesn't work for me.
In the above example, all P within the BODY should have the style
applied to them, so i did the following in my editor and ran it with
I.E 6.0, N.N. 7.1 and Mozilla 1.4:
<HTML>
<HEAD>
<TITLE>Test</TITLE>
<STYLE TYPE="text/css">
BODY > P {color: red}
</STYLE>
</HEAD>
<BODY>
<P>My name is Patrick</P>
</BODY>
<P>My name is Kristina</P>
</HTML>
Both sentences within <P> tags turn out red in Mozilla and N.N. and
remain black in I.E.
Now i understand that i am probably not supposed to place a P tag
outside of a BODY tag but since the CSS2 specification chooses that
example i had no choice.
From what i understand of the BODY > P {color: red} style, in my
example the sentence "My name is Patrick" should be red because that P
is within the BODY tag and "My name is Kristina" should remain black
because its P is outside the BODY tag.I don't get it?
Thanks to the pros for helping a struggling (But determined) CSS
student.
Patrick