Learn how to use Contextual Selector Group Selector in CSS - Technology & Web designing

Breaking

Saturday, 9 May 2020

Learn how to use Contextual Selector Group Selector in CSS

The Contextual Selector :

There may be situations when user want a given style to be applied to instance of one selector within another. For example, when <I>-----</I> tags occur inside <P>-----</P> tags, the text color should be green. User can do this by declaring the style tag.

Let's understand with an example

Programe :

In the above code, the <I> tag enclosed in the <P> tag will have text in green and the <I> tag enclosed in the <H1> tag will take the colour of <H1> tag.

Output :



Grouping selector :

This property can be used when same style has to be applied to different tags and it's takes longer time to write same style from formate to different tags. For this the Option is Group Selector.

See the example

Programme :

You can see in the above example that we have merge the same style to all the different tags to save out time.

Output :

No comments:

Post a Comment

If you have any doubts regarding this please comment or email us.