2

I have an element with a ng-list attribute. The very next sibling to this element is an <ol>. I want to write a CSS selector that selects this <ol>.

In other words, I want to write CSS that applies to an <ol> when the <ol> has an immediate previous sibling of [ng-list].

Possible?

1

2 Answers 2

4

It's called an adjacent sibling selector.

For starters, I would never ever write this CSS selector, you're tying to an angular attribute, it makes no sense. You should just give you OL a class.

[ng-list] + ol { /* rules here */ } 
Sign up to request clarification or add additional context in comments.

Comments

2

CSS doesn't have a 'previous element' selector yet.

Since you want to select the ol that immediately follows another element, use +, it will select only the specified element that immediately follows the former specified element.

In your case

[ng-list] + ol { /* css rules */ } 

Ref: 5.7 Adjacent sibling selectors

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.