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

Chapter 4. CSS Selectors > Simple Contextual Selectors

Simple Contextual Selectors

A contextual selector is a selector that takes into account the context in which the style is to be applied. That is, the specified style is applied to an element only if the element is in the specified context. An element’s context is formed by its ancestor elements and the elements that precede it. In this section, we look only at the ancestors. The section, “Advanced contextual selectors,” describes how other contexts can be added to a selector.

Suppose you were to write these two rules:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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