How to apply two CSS classes to a single element

前端 未结 7 800
Happy的楠姐
Happy的楠姐 2020-11-27 13:52

Can i apply 2 classes to a single div or span or any html element? For example:

aa

I tried and

7条回答
  •  执笔经年
    2020-11-27 14:35

    As others have pointed out, you simply delimit them with a space.

    However, knowing how the selectors work is also useful.

    Consider this piece of HTML...

    Using .a { ... } as a selector will select the first and third. However, if you want to select one which has both a and b, you can use the selector .a.b { ... }. Note that this won't work in IE6, it will simply select .b (the last one).

提交回复
热议问题