Saturday 23 April 2016

xhtml - CSS Parent/Ancestor Selector











I know this is a shot in the dark, but is there a way, using css only, CSS2, no jquery, no javascript, to select and style an element's ancestor? I've gone through the selectors but am posting this in case I missed something or there is a clever workaround.



For example, say I have a table with classname "test" nested inside a div. Is there some sort of:










div (with child) .test
{
/*styling, for div, not .test ...*/
}

Answer



There is no such thing as parent selector in CSS2 or CSS3. And there may never be, actually, because the whole "Cascading" part of CSS is not going to be pretty to deal with once you start doing parent selectors.




That's what jQuery is for :-)


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...