Apply style if element exists
I need to use CSS to apply style to class article ONLY if class subject is present inside .container
I was trying to use sibling selector, but it does not seem to work. What am I missing?
The adjacent sibling combinator is meant for sibling elements. Your selector wasn’t working because
.subject are not siblings,
.subject is a child of
.container .subject + .article
.article are siblings, therefore it should work.