CSS: The class selector The class selector is a way to select all of the elements with the specified class name, and apply styles to each of the matching elements. Declare a CSS class by using a dot (.) followed by the class name. You make up the class name yourself. After the class name you simply enter the properties/values that you want to assign to your class. The browser will look for all tags in the page that have a class attribute containing that class name.
**.class-name { property:value; }**
If you want to use the same class name for multiple elements, but each with a different style, you can prefix the dot with the HTML element name.
For example:
**p.large { font-size: 2em;}**
The class name can't contain a space, but it can contain hyphens or underscores. Any tag can have multiple space-separated class names.
## CSS ID Selectors
The id selector is a way to select only the element with the specified id, and apply styles to that element. The selector must start with a pound sign (#) and then the value of the id attribute. The browser will then look for a tag in the page that has an id attribute equal to that id.
The spelling and the casing must be exactly the same - #soon_gone is different from **#Soon_Gone.** The page should not have multiple tags with the same id every id should be unique.
**#id-name { property:value; }**
Again, similar to classes, if you want to use the same id name for multiple elements, but each with a different style, you can prefix the hash with the HTML element name.
**p#intro { font-size: 2em; }**
Note: ID applies to EVERY single thing with that specified element, while class applies only to the classes you gave to everything, so ID would make every h2 purple in ID for example, but class would only make the one h2 you gave the class to purple.
### CSS: The element selector
The element selector is a way to select all the elements with a given tag name in
a document, and apply the same styles to each element with the tag name.
Note that you should only write the tag name, and not write brackets around the
tag name — h1, not