0
What is descendent selectors?
Can anyone explain descendent selectors in easy way ? And can we write Id and class selectors in the tags like <em>, <span> etc ? And can we write class selector in div tag and inside that in p tag we will write an Id selector ?
3 Answers
+ 4
We can place id and class to any html element.
Just make sure when you use id, you can have only one id with same name, so for example:
You have div with id="container" you can't place this same id to another element.
About descendent selector, we use space
For example:
div p {
}
Here we select every p what is inside div, even if it is nested in another element
it is similar to child selector:
div > p {
}
Here we select every p what is direct child of div
Also read this:
https://www.w3schools.com/css/css_combinators.asp
Best is to check example:
https://code.sololearn.com/WZoVRFon46G9/?ref=app
0
Thank to you both I understood š