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

后端 未结 4 1617
春和景丽
春和景丽 2020-12-04 17:20

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 ea

4条回答
  •  青春惊慌失措
    2020-12-04 17:56

    this is known as a Child Combinator:

    A child combinator selector was added to be able to style the content of elements contained within other specified elements. For example, suppose one wants to set white as the color of hyperlinks inside of div tags for a certain class because they have a dark background. This can be accomplished by using a period to combine div with the class resources and a greater-than sign as a combinator to combine the pair with a, as shown below:

    div.resources > a{color: white;}
    

    (from http://www.xml.com/pub/a/2003/06/18/css3-selectors.html)

提交回复
热议问题