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

Adjacent Sibling Selectors
Precise Definitions of CSS Styles

By , About.com Guide

Cascading Style Sheets defines siblings as elements that are next to one another. They are also called adjacent elements. This means that you can define a style rule on an element based on what element immediately precedes it in the XHTML.

How to define a sibling rule:
  h1 + h2 { color : #00f; }

This rule says that any h2 that immediately follows an h1 should be colored blue.

Browser Support

The adjacent sibling selector is not supported in IE 6 and lower for Windows or Netscape 4 for Windows. It did work in Safari and Internet Explorer 5.2 for Macintosh.

Explore Web Design / HTML
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. CSS
  5. Advanced CSS
  6. Adjacent Sibling CSS Selectors>

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

All rights reserved.