What is contextual selector?

Using contextual selectors,

you publicize style qualities that are only applied when specific tags are nested within other tags.

Let's create a contextual selector that reasons all text with table cells to be red and smaller than the rest of our
 
Contextual selectors give you some control over the styles applied to tags in a specific order in your document. Keep in mind that a well-formed HTML document consists of nested tags, starting with the outermost <html> tag and working inward to individual <p> tags. As content is created within frames, tables, divisions, and other flow control elements, you build a tag nesting within tags.
 
Contextual Selectors

Contextual selectors are merely strings of two or more simple selectors separated by white space. These selectors can be assigned normal properties and, due to the rules of cascading order, they will take precedence over simple selectors. For example, the contextual selector in

P EM { background: yellow }
 
"Contextual selectors" in CSS allow you to specify different styles for different parts of your document. You can assign styles directly to specific HTML tags, or you can create independent classes and assign them to tags in the HTML. Either approach lets you mix and match styles.
 
Last edited:
Back
Top