Day 4 Home

Selectors

CSS can address or select elements on a page in many different ways. Some of the most common ways are as follows:

  1. Type or Element selector: You can apply a style to every element of a paricular type. For example, you can have the text in contents of the body be arial type font:
  2.                 body{
                    font-family: Arial;
                }
                
  3. Class: You can apply visual style to a specific html elements by adding the class attribute. You may call your class by any name, as an example, you can write class attributes like this: class="important". Classes allow you to target specific elements and modify them. This is often used with the div element for layout purposes.
  4.                 .important {
                    font-family: Arial;
                }
                
  5. ID : You can also apply visual style to a specific html elements by adding the I D attribute. I Ds give you the ability to change style and content using Javascript. I Ds are useful for adressing specific elements with unique I D s and therefore, you should only use an I D once.
  6.                 #top {
                    font-family: Arial;
                }
                

Box Model