• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. CSS Selectors > Advanced Contextual Selectors

Advanced Contextual Selectors

The context of an element consists of all the element’s ancestors and all elements that precede it in the document. It is not possible to look at elements that follow an element because browsers often need to be able to decide on the style of an element before the rest of the document comes in. The most common contextual selector is the one that was explained earlier, in the section, “Simple contextual selectors.” It only checks whether an element is inside some other element, without regard for how far removed that ancestor is.

Two other contextual selectors, the child selector and the sibling selector, give precise control over the relation between the element to select and its context. In combination with the first-child pseudo-class explained next, these can be used to trace out a path from some element to the element you want to select.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint