sajisweetgirl Posted June 25, 2013 Share Posted June 25, 2013 HiI just started learning css from w3schools tutorials ,I have a question in chapter nesting selectors .in this style p{..............} .marked{...................} .marked p{...............} p.marked{................} whats the difference between 'p.marked' and '.marked p' ?! thanks Link to comment Share on other sites More sharing options...
niche Posted June 25, 2013 Share Posted June 25, 2013 See the try-it-yourself at:http://www.w3schools.com/css/css_grouping_nesting.asp If you already have, what is it about the try-it-yourself that you didn't expect? Link to comment Share on other sites More sharing options...
sajisweetgirl Posted June 25, 2013 Author Share Posted June 25, 2013 I checked it !i know that p means paragraph tag and .marked is a class and p.marked is all paragraphs with the class marked , but whats .marked p? when do you use it? Link to comment Share on other sites More sharing options...
sajisweetgirl Posted June 25, 2013 Author Share Posted June 25, 2013 .marked p means all paragraphs in all element with class marked? Is that right? Link to comment Share on other sites More sharing options...
niche Posted June 25, 2013 Share Posted June 25, 2013 (edited) A third style is specified only for p elements within elements with class="marked". EDIT: You must look at the HTML also. Edited June 25, 2013 by niche Link to comment Share on other sites More sharing options...
jeffman Posted June 25, 2013 Share Posted June 25, 2013 (edited) .marked p corresponds to the nested <p> element in either of these HTML structures: <p class="marked"> <p>First descendent</p></p> <div class="marked"> <table> <tr> <td> <p>Arbitrary descendent</p> </td> </tr> </table></div> Edited June 25, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
dsonesuk Posted June 25, 2013 Share Posted June 25, 2013 paragraph within another paragraph element is invalid, bad bad example. tut tut 1 Link to comment Share on other sites More sharing options...
jeffman Posted June 25, 2013 Share Posted June 25, 2013 (edited) paragraph within another paragraph element is invalid, bad bad example. tut tutTrue. It sort of looked like OP's CSS wants to do it that way. A better example would look like this:<div class="marked"> <p>Hello</p></div> Edited June 25, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
sajisweetgirl Posted June 25, 2013 Author Share Posted June 25, 2013 Got it! thank you all Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now