Contents:
- Overview
- Selectors
- Properties
- Units
- [Box Model](#Box Model)
- [Include CSS](#Include CSS)
- CSS defines appearance of page
- composed of rules
- each rule has a selector and some declarations
- example
header{
color: blue;
font-family: Verdana, sans-serif;
}-
basic
- select by tag name:
header{declarations} - select by name:
.name{declarations} - select by id:
#id{declarations} - select by attribute value:
[attribute="value"]{declarations} - combine selectors:
p.alert a {color: blue} - select by descendants
foo bar {declarations} - right-angle bracket to select child rather than descendant
ul.fruits > li {color: blue}
- select by tag name:
-
pseudo-class
- elements can be selected by current state
- common used pseudo-classes
foo:first-child: first child of its parentfoo:last-child: last child of its parentfoo:empty: elements with no children- form elements
input:checked
- hyperlink elements
a:link: all hyperlinks not visiteda:visited
- interactive elements
foo:active: elements being pressed onfoo:hover: elements being hovered overfoo:focus: elements that are selected
- common used properties
background-imagebackground-color- tables
border-collapse
borderandborder-radiusfloat: left/rightandclear:bothcursor:pointerfontlist-style-typetext-aligndisplay
- load external stylesheets
<link rel="stylesheet" type="text/css" href="path/to/stylesheet.css"/>
- embed stylesheets in the document
<style type="text/css"> styles{ go : here; } </style> - inline styles using style attribute
<p style="color:red">Content</p>