Visit Mozilla.org

CSS:Adjacent sibling selectors

From MDC

« CSS « CSS Reference

[edit] Summary

The + combinator separates two selectors and matches an 2nd element only if it is immediately following to the 1st.

[edit] Syntax

.class1 + .class2 { style properties }


[edit] Examples

li + li {
  color: red;
}

...where...

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

... should look like ...

  • One
  • Two
  • Three

[edit] Notes