12/03/2007

There is another selector called Descendant Selectors

Descendant Selectors

We can specify the style of an element only when it is inside another element. To accomplish this, we use the concept of descendant selectors.

The syntax for declaring a descendant selector is:

[Parent Selector] [Child Selector] {
property:value;
...
}

The style defined above will apply to child selectors only when they are inside the parent selector. Such declarations can go on for more than two levels.

For example, in the declaration below,

li b {
color:yellow;
}

means that text in the element inside the
  • element will be yellow. Text in the elements not within the
  • element will not be affected by this stylesheet.
  • No comments: