Jump to content

Searching opposite of "+": Predecessor element


pstein

Recommended Posts

Assume I have the following code
 

<p>
<div>.aaa...</div>
<div class="foobar">.bbb..</div>
<div>.ccc..</div>
<p>

then I can address the <div>element FOLLOWING the <div> element with class=foobar by

div.foobar + div

will address the <div> with ccc inside

Ok, but how do I address the opposite: The predecessor=the <div> with aaa inside?

div.foobar - div

seems not to work

Peter

Link to comment
Share on other sites

CSS does not have predecessor or ancestor selectors because the CSS rendering engine is stateless, it only moves forward and down the DOM tree without having to backtrack. Being stateless means that it is efficient and can render pages really quickly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...