CSS

Introduction

selector {
property1: value1;
property2: value2 value 3 value4;
}

Selectors

Combinators

Properties

More cheatsheets:

Font-size note

Specificity

A CSS declaration that is more specific will take precedence over ones that are less specific.

The order from the higher:

When the level is the same, more selectors, counted from higher level, has higher specificity.

Universal selector (*) and combinators (+, ~, >, a-space) do not add specificity.

Inheritence

Certain CSS properties can be inherited by element descendant. Typography based properties like color and font are usually inherited, most others are not. Directly targeted properties will be applied instead of the inheritance though, even if the inheritance has higher specificity.

Rule Order

If all factors have been taken into account and it's still a tie, rule that was last defined is the winner.

Adding CSS to HTML

Priority: inline > internal > external