Difference between the selectors div + p (plus) and div ~ p (tilde)

前端 未结 4 841
囚心锁ツ
囚心锁ツ 2020-11-29 21:46

The way that w3schools phrases it, they sound the same.

W3Schools\' CSS reference

div + p
Selects all

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 21:54

    consider this example:

    p + p { /* the first p immediately after a preceding p */
       color: red; 
    } 
    
    p ~ p { /* all p's after a preceding p */
       font-weight: bold;
    } 

    1

    separator

    2

    3

提交回复
热议问题