Saturday, October 26, 2019

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

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...