p #test VS #test p
For the last question, the ‘correct answer’ is: #test p But wouldn’t: p #test be just as right? The first says “all classes named ‘test’ of <p>” The second says “all <p>s with the class of ‘test’” I just find the second more readable, and both ways work, yet I got it wrong when I entered it the second way.
2/7/2019 2:48:10 PMChester
1 AnswerNew Answer
Hi Chester ! An "#" stands for ID attribute, class is a period "." and therefore both work, because ID should be unique and has priority over element AFAIK (may anybody please correct me if I am wrong) p #test would select all P with ID test. Since ID should be unique, it only selects the element with ID test. #test p would select the only one P element with ID test, if your P element has an ID attribute. As for classes: p .test would select all children of P with class test. .test p would select all P elements which are children of elements with class test. But only p.test would select all P with class test. Take a look at my code: https://code.sololearn.com/WIx3N4EbAU6P/?ref=app