CSS Notes:
- Cascading Style Sheets!
- CSS basically allows you to mass add attributes to html tags
- CSS format:
selector { property: value; property: value; }There are 3 basic selectors:
- type selectors: used to select HTML elements by element name. This is like your h1, p, a, etc. Your selector will simply be the name of the tag.
- class selectors: used to select HTML elements by a specific class value. classes can be added to html tags by using the class attribute. html tags may have as many classes as you want. Your selector will be a
.followed by the class name, like.blueBackground - id selectors: used to select an HTML element associated with a specific id value. IDs can be added to html tags by using the id attribute. You may only use an id once, and you can only assign one id to each tag! Your selector will be a
#followed by the id name, like#blueButtonType selectors will be applied first, then class, then id. Within each group, the most specific group gets applied. If you have the following css:body { background: red; } .myText { background: blue; } h1 { background: green; }a
ptag with myText class will be colored blue, aptag within the body but not a.myTextclass will color the background green as it is more specific, and everywhere else on the page will be red as neither the.myTextclass nor theh1orbodytag applies.
New properties:
background- background color likeredcolor- color of text likewhitefont-family- font of text, likeArialtext-align- align left, right, center.