CSS Dot Notation Naming Convention

后端 未结 6 1612
余生分开走
余生分开走 2020-12-31 13:48

I am getting started with learning CSS.

While looking through the tutorial on w3schools.

I realized some of the example start with

.awesom         


        
6条回答
  •  旧时难觅i
    2020-12-31 14:37

    The dot denotes that the selector is a class. So it will select elements in your page as such:

    .awesome-text-box {
    
    }
    

    Whereas without the dot denotes an element name. Such as:

    div {
    
    }
    

    In the other example you gave, the dot notation is using chaining this is where you can select an element with numerous conditions. In your example:

    p.one {
    
    }
    // Will find
    

    // However it will not find

    Whilst I am here I can give you a list of other common selectors too:

    • #awesome-text-box =>
      => ID
    • .btn.btn-style-1 => => Chaining classes
    • p > span =>

      => Child
    • p span =>

      => Descendant (anything below)

    • p + span =>

      => Sibling

提交回复
热议问题