CSS3 element1~element2Selectors
Complete CSS Selector Reference Manual
Example
Set the background color of every ul element that follows a p element under the same parent element:
p~ul
{
background:#ff0000;
}
{
background:#ff0000;
}
Try it Yourself »
Definition and Usage
element1~element2The selector matches element2 that appears after element1.
element1andelement2These two elements must have the same parent element, butelement2need not be immediately afterelement1After.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support it.element1~element2Selector.
Note:To use this selector in IE8 and its earlier versions, you must declare<!DOCTYPE>。
other extensions