Table of Contents
- Cascade Order
- All about Units:
Cascade Order discussion
- the source document
- the user's browser customization
- the browser default
- Collect all declaration
- Sort by importance as follows
- More specific rules override more general ones :: Specificity is defined based on how many IDs, classes, and element names are involved, as well as whether the
!importantdeclaration was used.
- When multiple rules of the same "specificity level" exist :: Whichever one appears last wins.
initialkeyword is used to set a CSS property to its default value.
inheritkeyword specifies that a property should inherit its value from its parent element.
- Both keywords can be used for any CSS property, and on any HTML element.
All about Units:
rem, etc. discussion
- General units
em, ex, ch
- equal to the inherited font size. If the font size of a
<div>is set to
<div>is equivalent to
- x-height of the current font OR one-half of one
- the width of the zero character, 0
chif you want more granular control
- Relative to font-size of the root element
vw, vh, vmin, vmax
- Relative to 1% of the width of the viewport
- Relative to 1% of the height of the viewport
- Relative to 1% of viewport's* smaller dimension
- Relative to 1% of viewport's* larger dimension
cm, mm, in, pt, pc
- inches (1in = 96px = 2.54cm)
- points (1pt = 1/72 of 1in)
- picas (1pc = 12 pt)
|em||Relative to the font-size of the element (2em means 2 times the size of the current font)|
|ex||Relative to the x-height of the current font (rarely used)|
|ch||Relative to width of the "0" (zero)|