English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Adjacent sibling selector (+) Between two selectors, when the second element immediately follows the first element, and both elements are children of the same parent element, the second element will be selected.
Complete CSS selector reference manual
Select all <p> elements that immediately follow the first <div> element and the first <span> element:
<!DOCTYPE html> <html> <title>Basic Tutorial Website (oldtoolbag.com)</title> <head> <style> div+p { background-color:red; color:white; } div+span { background-color: DodgerBlue; } </style> </head> <body> <h1>Welcome to Basic Tutorial Website (www.oldtoolbag.com)</h1> <div> <p>The URL of our website is: www.oldtoolbag.com.</p> <p>The name of our website is: Basic Tutorial Website.</p> <span>Demonstrate adjacent sibling selector</span> <span>Demonstrate adjacent sibling selector</span> </div> <p>Our website provides various basic tutorials for you to learn. Learn the basics well, and you can go further! </p> </body> </html>Test and see ‹/›
former_element + target_element { style properties }
element+element Adjacent sibling selectors are used to select the element immediately following the specified first element (not internal).
IEFirefoxOperaChromeSafari
All major browsers support element+element Adjacent sibling selector.
Note: element+elementIE8Must be declared when running in <!DOCTYPE>Complete CSS selector reference manual