139
CHAPTER
Advanced CSS 5
How complex can my contextual selectors be?
You can create contextual selectors as complex as
you need. For example, if you wanted to apply a
style to an image that was inside a paragraph,
which in turn was inside a div with an ID of
content, you could write #content p img
and successfully target the image.
Do I need to use any special characters within
the contextual selector?
No. A contextual selector is a list of selectors
separated by spaces. A comma-separated list of
selectors applies the style to each of the elements
in the list, as shown earlier in this chapter.
● When you view the page
in the browser, the child
element has the style
applied to it.
3 Press.
4 Type {.
5 Type one or more style
rules to apply to the
child element.
6 Press.
7 Type }.
5
4
7
TIPS