CSS Flashcards
CSS stands for…
Cascading Style Sheets
It is a language for describing the presentation of web pages.
inline CSS definition
< style=”background-color: tomato” > My text < /p >
internal CSS definition
< style > p { background-color: tomato < /style >
All paragraphs are now tomatoes!
External CSS definition
One or more CSS files included in the html:
in the head tags:
< link rel=”stylesheet” type=”text/css” href=”style.css” >
CSS rule set syntax
selector { property: value; ... ... }
CSS selectors
by element(tag) p {...} by class .thisClass{...} by id #thisID{...}
CSS length units
Pixel (px): absolute size, different on different monitors, bad for accessibility
EM, %, and rem are relative sizes: 1em = as large ad your base font size.
CSS cascade…order of importance
Low to high: User agent User Author Author !important User !important
CSS cascade…specificity
The more specific declaration “wins”
low to high: element(tag) selectors class selector id selectors inline style
CSS combinators
el1, el2 {...} selector list el1 > el2 {...} el2 is a direct child of el1 el1 el2 {...} el2 is a descendant of el1 el1 + el2{...} el1 is the direct sibling of el2 el1 ~ el2{...} el1 and el2 are general siblings
CSS attribute selectors
selector[html_attribute=”value”]{…}
CSS Pseudo classes
selector:pseudo-class
fx:
a:visited{…};
CSS Pseudo Elements
selector::pseudo-element
fx:
::first-line{…}
CSS the box model
When html is rendered, a box is drawn around each element. Additionally there are optional areas:
padding, border, margin
Padding vs Margin
Padding adds space within the element
Margin adds space around an element