Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "+" (plus sign) CSS selector mean?

For example:

p + p {   /* Some declarations */ } 

I don't know what the + means. What's the difference between this and just defining a style for p without + p?

like image 636
gday Avatar asked Jul 16 '09 19:07

gday


People also ask

What are CSS plus points?

The + (plus sign) selector in CSS is used to select the elements that are placed immediately next to the specified element but not inside the specified element.

What does '>' mean in CSS?

The greater than sign (>) selector in CSS is used to select the element with a specific parent. It is called as element > element selector. It is also known as the child combinator selector which means that it selects only those elements which are direct children of a parent.


1 Answers

See adjacent selectors on W3.org.

In this case, the selector means that the style applies only to paragraphs directly following another paragraph.

A plain p selector would apply the style to every paragraph in the page.


This will only work on IE7 or above. In IE6, the style will not be applied to any elements. This also goes for the > combinator, by the way.

See also Microsoft's overview for CSS compatibility in Internet Explorer.

like image 169
Thorarin Avatar answered Oct 02 '22 04:10

Thorarin