Jump to content
pstein

Searching opposite of "+": Predecessor element

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

Share this post


Link to post
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.

Share this post


Link to post
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

×