Little Web Hut
(Cascading Style Sheets) CSS 2.1 Reference

CSS Descendant Selector

 

What is a CSS Descendant Selector?

  • The descendant selector specifies an element that is a descendant of another element. The syntax is two or more selectors separated by whitespace. The descendant selector is listed last. In the following example, the color property will be set to red for all <strong> elements that are descendants of <div> elements. The style is NOT applied to the second <strong> element.
CSS Example:
  div strong {color: red;}
  <div><p>The red style <strong>has been applied to this element.</strong></p></div>
  <p>The red style <strong>has not been applied to this element.</strong></p>
Test It HTML StyleTest It XHTML StyleTest It HTML5 Style