Search code examples
csscss-selectors

How is the "greater than" or ">" character used in CSS?


I have seen this character a number of times in CSS files but I have no idea how its used. Can anyone explain it to me and show how they are useful in making a page style easier?


Solution

  • It's a CSS child selector. P > SPAN means apply the style that follows to all SPAN tags that are children of a P tag.

    Note that "child" means "immediate descendant", not just any descendant. P SPAN is a descendant selector, applying the style that follows to all SPAN tags that are children of a P tag or recursively children of any other tag that is a child/descendant of a P tag. P > SPAN only applies to SPAN tags that are children of a P tag.