Tuesday, May 28, 2019

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?


Answer



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.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...