Specifies an adjacent sibling relationship between selector elements.
Syntax
| HTML | E + F { sRules } |
| Scripting | N/A |
Possible Values
| E | String that specifies the name of a document language element type or simple selector. |
| F | String that specifies the name of a document language element type or simple selector. |
| sRules | String that specifies one or more Cascading Style Sheets (CSS) attribute/value pairs. |
Remarks
The adjacent sibling combinator is a "plus sign" (+) character that separates two simple selectors. Whitespace is not significant.
A selector of the form "E+F" matches element F when it immediately follows sibling element E in the document tree, ignoring non-element nodes (such as text nodes and comments). Element E and F must share the same parent and E must immediately precede F. To match the first child of the parent, use the :first-child pseudo-class.
Note Requires Windows Internet Explorer 7 or later.
Note Combinators are enabled only in standards-compliant mode (strict
!DOCTYPE).
Example
The following example applies to the H2 that immediately follows an H1. The second H2 is not affected.
<![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>
<style>
H1 + H2 { text-indent:5px; color:red;}
</style>
</head>
<body>
<h1>First Header</h1>
<h2>Second Header</h2>
<h2>Third Header</h2>
</body>
</html>
Standards Information
See Also