Ali Ali - 2 months ago 10
CSS Question

Example of Selector grouping and Contextual Selector on CSS

I'm going to have an exam tomorrow and I'm trying to understand the meaning and the answer of

Selector grouping and Contextual Selector

While I searched all around google with many sources it starts to make me confuse because when I answer this on my previous test I got the answer wrong when I used the answer that I found from the internet, but the one below is the correct answer from our professor.

a. Selector grouping example

td, th, li { property: value; }

b. Contextual Selector example

table p { property: value; }


Can anyone please give me some more information what does selector grouping and contextual selector mean with some more example please.

Answer

Basically what you looking at is the following.

for

a. Selector grouping example 

   td, th, li { property: value; }

what the above is saying that you want to have the same value for the same property for all td,th, and li

b. Contextual Selector example 

   table p { property: value; } 

this one is saying that you want to set the value for <p> tags that belongs to <table> tags

so whenever you have a <p> in a <table>, then it will get effected.