If IDs in HTML should be unique, why sometimes I see in Css see something like div#nav-blue? -


since id should unique in html, why see in css selectors formatted (div#nav-blue), since it's obvious there no other element having id exccept div, aint writting #nav-blue makes more sense?

it no change or little.

you can reason : more visibility when maintain code. easier find, , remember each kind of element style.

the second reason priority of selector.

there different order of priority :

!important > #id > .class > element 

you can consider

 element = 1  .class = 10  #id = 100  !important= 1000 

and div#id = 101 > #id = 100

div#myid{    color:red;  }    #myid{    color:blue;  }    .myclass{    color:yellow;  }    div{    color:green;  }
<div class="myclass" id="myid">  text  </div>


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -