How do I select an element that has a certain class?

后端 未结 5 1330
清歌不尽
清歌不尽 2020-12-04 15:14

My understanding is that using element.class should allow for a specific element assigned to a class to receive different \"styling\" than the rest of the class

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 15:29

    h2.myClass is only valid for h2 elements which got the class myClass directly assigned.

    Your want to note it like this:

    .myClass h2
    

    Which selects all children of myClass which have the tagname h2

提交回复
热议问题