CSS Functions

What You’ll Learn
CSS value functions compute colors, sizes, transforms, and more. Start with calc(), clamp(), and var(), then explore color, gradient, filter, and grid helpers.
Function Index
Math Functions
Calculate sizes, clamp values, and use numeric helpers.
abs()TutorialReturn the absolute value of a number.
acos()TutorialInverse cosine returning an angle.
asin()TutorialInverse sine returning an angle.
atan()TutorialInverse tangent returning an angle.
calc()TutorialDo arithmetic with lengths, percentages, and numbers.
calc-size()Tutorialcompute values with calc-size().
clamp()TutorialClamp a preferred value between a min and max.
cos()TutorialTrigonometric cosine for angles.
exp()Tutoriale raised to a power.
hypot()TutorialSquare root of summed squares.
log()TutorialLogarithm of a number.
mod()TutorialModulus with divisor sign.
pow()TutorialRaise a base to a power.
progress()Tutorialcompute values with progress().
random()Tutorialcompute values with random().
rem()TutorialRemainder with dividend sign.
round()TutorialRound a number with a chosen strategy.
sign()TutorialSign of a number as -1, 0, or 1.
sin()TutorialTrigonometric sine for angles.
sqrt()TutorialSquare root of a number.
tan()TutorialTrigonometric tangent for angles.
Color Functions
Build and mix colors in modern color spaces.
alpha()Tutorialcompute values with alpha().
color()TutorialSpecify a color in a named color space.
color-mix()TutorialMix two colors in a chosen color space.
contrast-color()Tutorialcompute values with contrast-color().
device-cmyk()Tutorialcompute values with device-cmyk().
dynamic-range-limit-mix()Tutorialcompute values with dynamic-range-limit-mix().
hsl()TutorialDefine colors with hue, saturation, and lightness.
hwb()TutorialDefine colors with hue, whiteness, and blackness.
lab()TutorialDefine colors in the CIELAB color space.
lch()TutorialDefine colors with lightness, chroma, and hue.
light-dark()TutorialPick a light or dark color from the color scheme.
oklab()TutorialDefine colors in the Oklab color space.
oklch()TutorialDefine colors with Oklch lightness, chroma, and hue.
palette-mix()Tutorialcompute values with palette-mix().
rgb()TutorialDefine colors with red, green, blue, and alpha.
Image & Gradient Functions
Paint backgrounds with gradients and image sets.
conic-gradient()TutorialCreate a conic color gradient.
cross-fade()Tutorialcompute values with cross-fade().
element()Tutorialcompute values with element().
image()Tutorialcompute values with image().
image-set()TutorialChoose the best image for device resolution.
linear-gradient()TutorialCreate a linear color gradient.
paint()TutorialPaintWorklet-generated image value.
radial-gradient()TutorialCreate a radial color gradient.
repeating-conic-gradient()TutorialRepeat a conic gradient pattern.
repeating-linear-gradient()TutorialRepeat a linear gradient pattern.
repeating-radial-gradient()TutorialRepeat a radial gradient pattern.
Filter Functions
Adjust blur, brightness, contrast, and shadows.
blur()TutorialApply a Gaussian blur filter.
brightness()TutorialBrighten or darken a graphic.
drop-shadow()TutorialCast a shadow that follows alpha shape.
grayscale()TutorialConvert a graphic toward grayscale.
hue-rotate()TutorialRotate the hue of colors.
invert()TutorialInvert colors in a filter.
opacity()TutorialAdd transparency via a filter function.
saturate()TutorialIncrease or decrease saturation.
sepia()TutorialApply a sepia tone filter.
Transform Functions
Move, rotate, scale, and skew elements.
matrix()TutorialApply a 2D transformation matrix.
perspective()TutorialSet 3D perspective distance.
rotate()TutorialRotate an element around a point.
scale()TutorialScale an element up or down.
skew()TutorialSkew an element on the 2D plane.
translate()TutorialMove an element on the 2D plane.
Reference Functions
Read variables, URLs, attributes, and environment values.
attr()TutorialRead an HTML attribute into CSS.
env()TutorialUse environment variables like safe-area insets.
if()Tutorialcompute values with if().
type()Tutorialcompute values with type().
url()TutorialReference an external resource.
var()TutorialUse a CSS custom property value.
Grid Functions
Size and repeat CSS Grid tracks.
fit-content()TutorialClamp a size to available content space.
minmax()TutorialDefine a grid track size range.
repeat()TutorialRepeat grid tracks in a pattern.
Shape Functions
Create clip paths and geometric shapes.
circle()TutorialDefine a circle basic shape.
ellipse()TutorialDefine an ellipse basic shape.
inset()TutorialDefine an inset rectangle shape.
path()TutorialDefine a shape with an SVG path string.
polygon()TutorialDefine a polygon shape.
ray()Tutorialcompute values with ray().
rect()Tutorialcompute values with rect().
shape()Tutorialcompute values with shape().
superellipse()Tutorialcompute values with superellipse().
xywh()Tutorialcompute values with xywh().
Easing, Counters & Timelines
Timing curves, counters, scroll timelines, and tree counting.
anchor()TutorialResolve a length relative to an anchor element edge.
counter()TutorialOutput the current value of a CSS counter.
counters()TutorialOutput nested counter values.
cubic-bezier()TutorialDefine a custom cubic Bézier easing curve.
scroll()TutorialAnonymous scroll progress timeline.
steps()TutorialCreate a stepped timing function.
symbols()Tutorialcompute values with symbols().
view()TutorialAnonymous view progress timeline.
More Functions
Additional CSS value functions.
anchor-size()TutorialResolve a length relative to an anchor’s size.
annotation()Tutorialcompute values with annotation().
atan2()TutorialTwo-argument inverse tangent.
character-variant()Tutorialcompute values with character-variant().
contrast()TutorialChange image contrast.
layer()Tutorialcompute values with layer().
linear()TutorialLinear easing through listed points.
matrix3d()Tutorialcompute values with matrix3d().
max()TutorialPick the largest value from a list.
min()TutorialPick the smallest value from a list.
ornaments()Tutorialcompute values with ornaments().
rotate3d()Tutorialcompute values with rotate3d().
rotateX()TutorialRotate around the X axis.
rotateY()TutorialRotate around the Y axis.
rotateZ()TutorialRotate around the Z axis.
scale3d()Tutorialcompute values with scale3d().
scaleX()TutorialScale horizontally.
scaleY()TutorialScale vertically.
scaleZ()Tutorialcompute values with scaleZ().
sibling-count()TutorialCount of siblings including the element.
sibling-index()TutorialIndex of an element among its siblings.
skewX()TutorialSkew horizontally.
skewY()TutorialSkew vertically.
styleset()Tutorialcompute values with styleset().
stylistic()Tutorialcompute values with stylistic().
swash()Tutorialcompute values with swash().
translate3d()Tutorialcompute values with translate3d().
translateX()TutorialTranslate horizontally.
translateY()TutorialTranslate vertically.
translateZ()TutorialTranslate along the Z axis.
Frequently Asked Questions
Next: CSS calc() Function
Start with the first tutorial in this section.
CODETOFUN NEWS
Stay Ahead in Tech
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful
