From: MG on 27 Apr 2010 11:56 I am looking at an example that I found somewhere on the internet. I have put it up here: www.blighty.co.za The stylesheet has this: #sddm div {...... I thought it should be like this: #sddm li div {...... (or #sddm * div {...... ) Both versions seem to work the same. Are both permissable? When is it permissable to skip out a selector, for example the li in the above? Thanks MG
From: Harlan Messinger on 27 Apr 2010 13:28 MG wrote: > I am looking at an example that I found somewhere on the internet. I have > put it up here: > www.blighty.co.za > > > The stylesheet has this: > #sddm div {...... > > I thought it should be like this: > #sddm li div {...... > (or #sddm * div {...... ) > > Both versions seem to work the same. > > Are both permissable? > When is it permissable to skip out a selector, for example the li in the > above? Adjacency indicates that the second matched element is somewhere inside the first matched element, not limited to being one of the first element's children. #ssdm div matches any div that is a descendant of the element with ID ssdm at any level: child, grandchild, great-grandchild, etc. #ssdm>div matches only divs that are children of ssdm. #ssdm * div matches any div that is a descendant of ssdm UNLESS the div is a child of ssdm. #ssdm li div matches any div that is a descedant of an li that is a descendant of ssdm. It will match the div in the fragment <ul id="ssdm"><li><div>...</div></li></ul> and it will match all fourof the innermost divs in the fragment <div id="ssdm"><div><div><ul><li> <div><div><div>...</div></div><div>abc</div></div> </li></ul></div></div></div> Which to use in a case where multiple formulations will match the HTML as you happen to have it at the moment depends on how restrictive you need to be and how much flexibility you need.
From: MG on 27 Apr 2010 14:51 "Harlan Messinger" <hmessinger.removethis(a)comcast.net> wrote in message news:83ol5jFu0U1(a)mid.individual.net... > MG wrote: >> I am looking at an example that I found somewhere on the internet. I have >> put it up here: >> www.blighty.co.za >> >> >> The stylesheet has this: >> #sddm div {...... >> >> I thought it should be like this: >> #sddm li div {...... >> (or #sddm * div {...... ) >> >> Both versions seem to work the same. >> >> Are both permissable? >> When is it permissable to skip out a selector, for example the li in the >> above? > > Adjacency indicates that the second matched element is somewhere inside > the first matched element, not limited to being one of the first element's > children. > > #ssdm div matches any div that is a descendant of the element with ID ssdm > at any level: child, grandchild, great-grandchild, etc. > > #ssdm>div matches only divs that are children of ssdm. > > #ssdm * div matches any div that is a descendant of ssdm UNLESS the div is > a child of ssdm. > > #ssdm li div matches any div that is a descedant of an li that is a > descendant of ssdm. It will match the div in the fragment > > <ul id="ssdm"><li><div>...</div></li></ul> > > and it will match all fourof the innermost divs in the fragment > > <div id="ssdm"><div><div><ul><li> > <div><div><div>...</div></div><div>abc</div></div> > </li></ul></div></div></div> > > Which to use in a case where multiple formulations will match the HTML as > you happen to have it at the moment depends on how restrictive you need to > be and how much flexibility you need. Thanks for your excellent reply. Very helpful. MG
|
Pages: 1 Prev: One frame and many photos Next: What is a non-replaced element? |