Can I use DIV class and ID together in CSS?

后端 未结 9 1539
名媛妹妹
名媛妹妹 2020-12-25 10:21

Can I use DIV Class and ID together in CSS? For example:

--
9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-25 10:35

    Of course you can.

    Your HTML there is just fine. To style the elements with css you can use the following approaches:

    #y {
        ...
    }
    
    .x {
        ...
    }
    
    #y.x {
        ...
    }
    

    Also you can add as many classes as you wish to your element

    And you can style that element using a selector with any combination of the classes and id. For example:

    #id.classA.classB.classC {
         ...
    }
    
    #id.classC {
    }
    

提交回复
热议问题