top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is Contextual Selector in CSS ?

0 votes
696 views
What is Contextual Selector in CSS ?
posted Mar 20, 2014 by Nikita Sehgal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Source : http://lanoie.net/classes/CSS/selectors_and_structure/lectures/lecture9.html
Contextual selectors provide the ability to create rules specific to certain structural circumstances. As an example, say you need strong text to appear blue but only if it's found within an h1 element.

You could use a class selector. However, adding the class attribute to every instance of the strong tag that is located inside an h1 tag is extra work. For example:

.setcolor { color: blue; }

<h1>This is <strong class="setcolor">Strong<strong> Text</h1>
answer Mar 21, 2014 by Divya Bharti
...