What does the dot mean in CSS?

后端 未结 5 1563
离开以前
离开以前 2020-11-27 03:59

Can someone explain the difference for these two CSS selectors?

.work-container . h3 {
font-size: 14px;
margin-top: 0px;
font-weight: 600;
height: 27px;
} 
<         


        
5条回答
  •  遥遥无期
    2020-11-27 04:48

    A . prefix usually represents a class selector, but if it's immediately followed by whitespace then it's a syntax error.

    If I were to hazard a guess, then it's likely the author meant to say .work-container > h3, but missed the Shift key just as he was about to type the > character (the child combinator).

    Your second selector, .work-container h3, simply means any h3 that's contained within an element with a class called work-container.

提交回复
热议问题