1. Home
  2. Computing & Technology
  3. Web Design / HTML

What is a CSS Adjacent Sibling Selector?

By Jennifer Kyrnin, About.com

The CSS adjacent sibling selector applies to elements that are both children of the same parent element and they are directly next to one another. The element to be styled is the second element.

Define an adjacent sibling selector with a plus-sign (+).

li + li {
font-size : 2em ;
}

In an ordered list, all list items are siblings. But only the second and subsequent <li> elements are adjacent to other <li> elements. The first <li> does not have another <li> directly preceding it.

Be sure to test this selector when you plan to use it. Internet Explorer 6 and lower do not support this selector.

More Web Design / HTML Quick Tips

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. CSS
  5. CSS Selectors
  6. CSS Adjacent Sibling Selectors - What is a CSS Adjacent Sibling Selector

©2008 About.com, a part of The New York Times Company.

All rights reserved.