0

We know that with div + p in CSS we can select all p elements placed immediately after div elements, but can we do the opposite?

Example: jsfiddle.net/6afkbsfL/2

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
hiru
  • 153
  • 1
  • 7
  • Looks very similar to this: http://stackoverflow.com/questions/492786/css-selector-for-selecting-an-element-that-comes-before-another-element – Raibaz Aug 28 '14 at 17:02
  • Or this: [stackoverflow.com/questions/1014861/is-there-a-css-parent-selector](http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – GentlePurpleRain Aug 28 '14 at 17:03
  • Thanks! I didn't see those questions in the suggestion area :/ – hiru Aug 28 '14 at 17:22

2 Answers2

0

You can use the ~ selector. try p ~ div. See CSS Selector for more options.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
cirix81
  • 119
  • 3
0

If you can use JQuery, you can try $("div+p").prev() to get all the div placed immediately before a p

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
cirix81
  • 119
  • 3