Notice! *These posts are basically my learning notes.*
There can misinformation and mistakes :(
If you find any wrong info, please leave a comment and I will get to it asap!

Classes

Types of selectors

  • There are many ways of selecting HTML element from CSS
  • You can use the tag or id as selector
  • Using tag as selector is used often in bigger picture
  • But when getting into details, you sometimes need to select a single or just a few element out of the same tag
  • Id can be used for this but since ids are to be unique value, you can’t use the same id for multiple element
  • To solve this, in most cases, you will be using classes

What is Class

  • Class can be used in many places in repetition
    <span class="sample"> Hello World </span>
    
  • When selecting a class in CSS, you can select by adding a dot in front of the class name
    .sample {
      background-color: tomato;
    }
    
  • HTML Elements can have multiple classes by having spaces between class names
    <div class="class1 class2 class3">Many classes</div>
    
  • By utilizing tag selector and class selector, you can code CSS efficiently

Tags:

Categories:

Updated:

Leave a comment