Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select the preceding sibling of an element in CSS using selectors [duplicate]

Tags:

How to select the above element of an element in CSS using selectors

<li class="content">One</li> <li class="content">Two</li> <li class="content">Three</li> <li class="no-content">First</li> <li class="content">Four</li> <li class="content">Five</li> <li class="content">Six</li> 

Here I want to use the class no-content, so that I can get its above element <li class="content">Three</li>, using CSS selector.

like image 873
Justin John Avatar asked Apr 04 '12 06:04

Justin John


People also ask

How do I select a previous sibling in CSS?

No, there is no "previous sibling" selector. On a related note, ~ is for general successor sibling (meaning the element comes after this one, but not necessarily immediately after) and is a CSS3 selector. + is for next sibling and is CSS2.

What is general sibling selector in CSS?

The general sibling selector (~) selects all elements that are next siblings of a specified element.


1 Answers

This is not possible with pure CSS...

like image 68
Gatekeeper Avatar answered Sep 20 '22 17:09

Gatekeeper