Skip to main content
Updated with :has().
Source Link

Unfortunately css doesn't support parent selectors. :(
So the only way to do it is toYou can use javascript like the jQuery parent method.has():

Update: CSS Selectors Level 4 will support parent selectors! http://www.w3.org/TR/selectors4/#subject

div:has(input:focus), 
div:has(a:focus) {
    background: pink;
}

Unfortunately css doesn't support parent selectors. :( So the only way to do it is to use javascript like the [jQuery parent method][1].

Update: CSS Selectors Level 4 will support parent selectors! http://www.w3.org/TR/selectors4/#subject

Unfortunately css doesn't support parent selectors. :(
So the only way to do it is to use javascript like the jQuery parent method.

Update: CSS Selectors Level 4 will support parent selectors! http://www.w3.org/TR/selectors4/#subject

You can use has():

div:has(input:focus), 
div:has(a:focus) {
    background: pink;
}

Unfortunately css doesn't support parent selectors. :( So the only way to do it is to use javascript like the [jQuery parent method][1].

Update: CSS Selectors Level 4 will support parent selectors! http://www.w3.org/TR/selectors4/#subject

Add note about CSS Selectors Level 4 parent selectors
Source Link
Rowno
  • 3.4k
  • 2
  • 24
  • 14

Unfortunately css doesn't support parent selectors. :(
So the only way to do it is to use javascript like the jQuery parent method.

Update: CSS Selectors Level 4 will support parent selectors! http://www.w3.org/TR/selectors4/#subject

Unfortunately css doesn't support parent selectors. :(
So the only way to do it is to use javascript like the jQuery parent method.

Unfortunately css doesn't support parent selectors. :(
So the only way to do it is to use javascript like the jQuery parent method.

Update: CSS Selectors Level 4 will support parent selectors! http://www.w3.org/TR/selectors4/#subject

Source Link
Rowno
  • 3.4k
  • 2
  • 24
  • 14

Unfortunately css doesn't support parent selectors. :(
So the only way to do it is to use javascript like the jQuery parent method.