0% found this document useful (0 votes)
45 views2 pages

CSS Selector Guide for Developers

The document discusses four different CSS selectors: the descendant selector which selects all descendant elements, the child selector which selects only immediate children elements, the adjacent sibling selector which selects the element immediately following the specified element, and the general sibling selector which selects any sibling elements. Examples are provided for each selector type to select <p> elements within, children of, after, and siblings of <div> elements respectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

CSS Selector Guide for Developers

The document discusses four different CSS selectors: the descendant selector which selects all descendant elements, the child selector which selects only immediate children elements, the adjacent sibling selector which selects the element immediately following the specified element, and the general sibling selector which selects any sibling elements. Examples are provided for each selector type to select <p> elements within, children of, after, and siblings of <div> elements respectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Descendant Selector

The descendant selector matches all elements that are descendants of a


specified element.

The following example selects all <p> elements inside <div> elements:

Child Selector
The child selector selects all elements that are the immediate children of a
specified element.

The following example selects all <p> elements that are immediate children of a
<div> element:

Adjacent Sibling Selector


The adjacent sibling selector selects all elements that are the adjacent siblings
of a specified element.

Sibling elements must have the same parent element, and "adjacent" means
"immediately following".

The following example selects all <p> elements that are placed immediately
after <div> elements:

General Sibling Selector


The general sibling selector selects all elements that are siblings of a specified
element.

The following example selects all <p> elements that are siblings of <div>
elements:

You might also like