Jump to content

Please Explain The Adjacent Sibling Selectors


Maisara-WD

Recommended Posts

Hithis is a quote that I couldn't understand

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.
Can you explain it..??
Link to comment
Share on other sites

Here's an example.Given this CSS:

li { color:blue; }li + li { color: red; }

<ul><li>This text will be blue</li><li>This text will be red because it's an <li> element that follows another <li> element</li><li>This text will also be red for the same reason</li></ul>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...