Estelle Weyl | @estellevw | Github | Press key to advance.

Units & Values

  • Numeric data types
    • Integer
    • Number
    • Percentage
    • Dimensions
      • <length>
      • <angle>
      • <time>
      • <frequency>
      • <resolution>
  • Non-numeric data types
    • Keywords
      • Global values
      • all property
      • <position>
    • Strings
      • <string> and <ident>
      • Developer Tools
      • CSS Functions
        • <url()
        • <image> functions
        • All the CSS functions

Numeric data types

Numeric data types

0 to 9, or lots of them. Optional - or +
Float, with or without a decimal. Optional - or +
A fraction of some other value, and relative to that value
A <number> with a unit attached to it


  • 0 to 9, or lots of them.
  • Optional - or +


  • Float, with or without a decimal.
  • Optional - or +


  • A fraction of some other value
    line-height: 60%;
    width: 60%;
  • Relative to that value
    li {height: 300px;} 
    pre {height: 33.33%;}


<number> with a unit

  • <length>
  • <angle>
  • <time>
  • <frequency>
  • <resolution>



Actual physical measurements (that might not match a ruler).
cm, mm, Q, in, pt, pc, px


Relative to some other measurement.
em, ex, cap, ch, ic, rem, lh, rlh vw, vh, vi, vb, vmin, vmax

Note: <length-percentage>

Absolute units of length

Unit Name Equivalent to
cm Centimeters 1cm = 96px/2.54
mm Millimeters 1mm = 1/10th of 1cm
Q Quarter-millimeters 1Q = 1/40th of 1cm
in Inches 1in = 2.54cm = 96px
pc Picas 1pc = 1/16th of 1in
pt Points 1pt = 1/72th of 1in
px Pixels 1px* = 1/96th of 1in
One pixel. For screen displays, it traditionally represents one device pixel (dot). When hi-dpi (like printers and phones) 1px = 1/96th of 1in.

Relative units of length

Unit Relative to
em Font size of the element.
ex x-height of the element's font.
ch Average character advance of a narrow glyph in the element’s font, as represented by the “0” (ZERO, U+0030) glyph.
rem Font size of the root element.
vw 1% of viewport's width.
vh 1% of viewport's height.
vmin 1% of viewport's smaller dimension.
vmax 1% of viewport's larger dimension.

viewport lengths

vw | vh | vmin | vmax
5vw     /* 5% of the width of the viewport */
7vh     /* 7% of the height of the viewport */
4vmin   /* 4% of the viewport height or width, whichever is smaller */
8vmax   /* 8% of the viewport height or width, whichever is larger */

Relative units of length

Unit Relative to
cap Cap height (the nominal height of capital letters) of the element's font.
ic Average character advance of a full width glyph in the element’s font, as represented by the “水” (CJK water ideograph, U+6C34) glyph.
lh Line height of the element.
rlh Line height of the root element.
vi 1% of viewport's size in the root element's inline axis.
vb 1% of viewport's size in the root element's block axis.

Newer values

2vi     /* 1% of containing block, in the direction of the root element’s inline axis.
    4vb     /* 4% of the containing block, in the direction of the root element’s block axis.

Length Units

Try it out

<angle> Units

Angle values are represented by <angle> in the spec:

Unit Name Description
deg Degrees There are 360 degrees in a full circle.
grad Gradians There are 400 gradians in a full circle.
rad Radians There are 2π radians in a full circle.
turn Turns There is 1 turn in a full circle.

Angle Units

Try it out

Angle Units

conic in supporting browsers

<time units

Time values are represented by the type <time>.

Unit Name Description
s Seconds
ms Milliseconds There are 1,000 milliseconds in a second.

The unit identifier -- the s or ms -- is required.

<ime> values

Try it out


Frequency values are represented by the type <frequency>.

Unit Name Description
Hz Hertz Represents the number of occurances per second.
kHz KiloHertz A kiloHertz is 1000 Hertz.

1Hz, which can also be written as 1hz or 1HZ, is one cycle per second.


Resolution units are represented by the type <resolution>.

Unit Description
dpi Dots per inch.
dpcm Dots per centimetre.
dppx, x Dots per px unit.

Represents the size of a single dot in a graphical representation, such as a screen, by indicating how many of these dots fit in a CSS inch, centimeter, or pixel.

<resolution> units

Try it out

Non-numeric data types


Global property values

Explicit Defaulting: CSS-wide property values

Sets property to its initial value.
Makes element's property the same as its parent.
Resets to inherited value if it inherits from its parent. Otherwise, set to initial value.

all property

all property lets you reset all properties to their initial, inherited, reverted, or unset state at once.

all: initial | inherit | unset | revert

cascade matters!

p {
  color: red;
  all: unset;
div {
  all: unset;
  color: blue;

Impacts all properties except unicode-bidi and direction.

New: Global property value

Resets property to UA stylesheet value (or user stylesheet, if any exist). (FF/Saf)


none / 0
Often seen in the wild. Valid when valid, but better to use initial to undo instead.

all property

Custom properties are not reset by the all property

initial | inherit | unset | revert

The all property resets all of an element's properties, except unicode-bidi and direction).

It can set properties to their initial or inherited values, or to the values specified in another stylesheet origin.

Specifies that all the element's properties should be changed to their initial values.
Specifies that all the element's properties should be changed to their inherited values.
Specifies that all the element's properties should be changed to their inherited values if they inherit by default, or to their initial values if not.
Specifies behavior that depends on the stylesheet origin to which the declaration belongs

Keyword values

Supported text-align values

left | right | center | justify | start | end | match-parent
/* Keyword values */         /* Global values */
text-align: left;            text-align: inherit;
text-align: right;           text-align: initial;
text-align: center;          text-align: unset;
text-align: justify;         text-align: revert;
text-align: start;
text-align: end;
text-align: match-parent;
  • appear literally, without quotes
  • case-insensitive
  • will review as we look at the property
  • Avoid in custom identifiers



center | top | right | bottom | left 
  • Specified with one or two keywords
  • Optional offsets on TRBL


 <percentage> | <length>


  • position can be outside the parent

Mixed values

border-width property

[ <length> | thick | medium | thin ]{1,4}
border-width: 1px thin;
border-width: thick thin thin thick;
border-width: medium;
border-width: 5px 10px thin thick; 




  • Quoted string of characters
  • Double or single quotes
  • Case-sensitive
  • HTML entities (like &amp;) won't be parsed
  • Unicode characters start with a \, or correct charset
  • Not parsed
content: ' (pdf)';
font-family: "myAwesomeFont", serif;
quotes: "«" '»' "‹" '›';


<ident> or <custom-ident>

  • idents, or custom identifiers, are unquoted
  • case-sensitive
  • can contain [A-Za-z0-9], hyphen (-), underscore (_), escaped character preceded by a backslash (\), and unicode characters (\123)
  • can NOT start with a digit, two hyphens, a hyphen+digit
  • can NOT be unset, initial, reset, inherit, or none
  • Should not be a property name or keyword value used elsewhere in CSS

<custom-ident> use cases

counter-reset: yourCounter;
counter-increment: myCounter;

grid-row-start: someGridArea;
grid-row-end: someOtherGridArea;
grid-column-start: anotherArea;
grid-column-end: oneMore;

Reading the specifictions

Property names as values == <custom-ident>

will-change: transform;
transition-property: opacity;

<custom-ident> | <string>

animation-name: myAnimation; 

@keyframes 'myAnimation' {
    0% {transform: translatex(0);}
  100% {transform: translatex(100vw);}

font-family:  Helvetica Neue;
font-family: "Helvetica Neue";


Inspect how you can increase and decrease length units. Arrow up and down to increase / decrease. With Shift and Alt to jump by 10 and 0.1 respectively.

Clear out a keyword, and hit up or down to see all the keyword option values. This shows keyword values only.

CSS Functions

<url> function

Simple usage



@document url("") { ... }  
@import url("");
@namespace url(;

Properties accepting <url> function

background-image: url("");
list-style-image: url('../images/bullet.jpg');

content: url("pdficon.jpg");
cursor: url(mycursor.cur);

border-image-source: url(/media/diamonds.png);
src: url('fantasticfont.woff');

offset-path: url(#path);
mask-image: url("masks.svg#mask1");

Properties accepting <url> function

background: url('') bottom right repeat-x blue;

border-image: url("/media/diamonds.png") 30 fill / 30px / 30px space;

background-image: cross-fade(20% url(first.png), url(second.png));

mask-image: image(url(mask.png), skyblue, linear-gradient(rgba(0, 0, 0, 1.0), transparent);

content: url(star.svg) url(star.svg) url(star.svg) url(star.svg) url(star.svg); 

<image> functions

linear-gradient(blue, red)
radial-gradient(blue, red)
conic-gradient(blue, red)
repeating-linear-gradient(blue, red 20%)
repeating-radial-gradient(blue, red 20%)
repeating-conic-gradient(blue, red 20%)
image(ltr 'arrow.png#xywh=0,0,16,16', red) 
cross-fade(url(twenty.png) 20%, url(eighty.png)) 
image-set('test.jpg' 1x, 'test-2x.jpg' 2x)

Other CSS Functions


  • rotate()
  • rotate3d()
  • rotateX()
  • rotateY()
  • rotateZ()
  • saturate()
  • matrix()
  • matrix3d()
  • scale()
  • scale3d()
  • scaleX()
  • scaleY()
  • scaleZ()
  • skew()
  • skewX()
  • skewY()
  • translate()
  • translate3d()
  • translateX()
  • translateY()
  • translateZ()
  • perspective()


  • attr()
  • counter()
  • counters()
  • target-counter()
  • target-counters()
  • target-text()


  • blur()
  • brightness()
  • contrast()
  • drop-shadow()
  • grayscale()
  • hue-rotate()
  • invert()
  • opacity()
  • sepia()

Other CSS Functions


  • annotation()
  • character-variant()
  • ornaments()
  • styleset()
  • stylistic()
  • swash()


  • symbols()


  • calc()
  • clamp()
  • max()
  • min()
  • minmax()
  • fit-content()
  • repeat()


  • cirlcle()
  • ellipse()
  • inset()
  • path()
  • polygon()
  • rect()


  • hsl()
  • hsla()
  • rgb()
  • rgba()


  • cubic-bezier()
  • steps()


  • env()
  • var()

Colors & Transparency

Next ➹