ترکیب (+
) adjacent sibling combinator دو انتخابگر را از هم جدا میکند و زمانی تطابق انجام میشود که انتخابگر دوم بلافاصله بعد از انتخابگر اول آمده باشد و هر فرزند یک والد element
باشند.
/* باشند img پارگرافهایی که بلافاصله بعد از */
img + p {
font-style: bold;
}
Syntax
former_element + target_element { style properties }
Example
CSS
li:first-of-type + li {
color: red;
}
HTML
<ul>
<li>One</li>
<li>Two!</li>
<li>Three</li>
</ul>
Result
Specifications
Specification | Status | Comment |
---|---|---|
Selectors Level 4 The definition of 'next-sibling combinator' in that specification. |
Working Draft | Renames it the "next-sibling" combinator. |
Selectors Level 3 The definition of 'Adjacent sibling combinator' in that specification. |
Recommendation | |
CSS Level 2 (Revision 1) The definition of 'Adjacent sibling selectors' in that specification. |
Recommendation | Initial definition. |
Browser compatibility
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.