Monday, July 18, 2016

What are the most frequently used CSS selector?

The most frequently used CSS selector are:

  1. Element selector (HTML tag selector)
  2. Class selector 
  3. ID selector    
Element selector (HTML tag selector):
<div class="first" id="first">First content</div>

<style>
div{
   background-color:blue;
}
</style>

Class selector:
<div class="first" id="first">First content</div>

<style>
.first{
   background-color:blue;
}
</style>

ID selector:
<div class="first" id="thisID">First content</div>

<style>
#thisID{
   background-color:blue;
}
</style>

No comments:

Post a Comment