인접 형제 결합자

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

인접 형제 결합자(+)는 앞에서 지정한 요소의 바로 다음에 위치하는 형제 요소만 선택합니다.

css
/* Paragraphs that come immediately after any image */
img + p {
  font-weight: bold;
}

구문

former_element + target_element { style properties }

예제

CSS

css
li:first-of-type + li {
  color: red;
}

HTML

html
<ul>
  <li>One</li>
  <li>Two!</li>
  <li>Three</li>
</ul>

결과

명세

Specification
Selectors Level 4
# adjacent-sibling-combinators

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Next-sibling combinator (A + B)

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

같이 보기