postcss-preset-env

Features

all Property

A property for defining the reset of all properties of an element

/* all-property */
a {
all: initial;
}

A pseudo-class for matching anchor elements independent of whether they have been visited

/* any-link-pseudo-class */
nav :any-link > span {
background-color: yellow;
}

:blank Empty-Value Pseudo-Class

A pseudo-class for matching form elements when they are empty

/* blank-pseudo-class */
input:blank {
background-color: yellow;
}

Break Properties

Properties for defining the break behavior between and within boxes

/* break-properties */
a {
break-inside: avoid;
break-before: avoid-column;
break-after: always;
}

CSS Cascade Layers

The @layer at-rule allows authors to explicitly layer their styles in the cascade, before specificity and order of appearance are considered.

/* cascade-layers */
/* Un-layered styles have the highest priority */
a {
color: mediumvioletred;
}

@layer defaults {
a { color: maroon; }
}

Case-Insensitive Attributes

An attribute selector matching attribute values case-insensitively

/* case-insensitive-attributes */
[frame=hsides i] {
border-style: solid none;
}

clamp Function

The clamp() CSS function clamps a value between an upper and lower bound. It enables selecting a middle value within a range of values between a defined minimum and maximum.

/* clamp */
button {
font-size: clamp(1rem, 2.5vw, 2rem);
}

color() Function

A function that allows a color to be specified in a particular, specified color space rather than the implicit sRGB color space that most of the other color functions operate in.

/* color-function */
p {
color: color(display-p3 1 0.5 0);
color: color(display-p3 1 0.5 0 / .5);
}

Color Functional Notation

A space and slash separated notation for specifying colors

/* color-functional-notation */
em {
background-color: hsl(120deg 100% 25%);
color: rgb(0 255 0);
}

Custom Media Queries

An at-rule for defining aliases that represent media queries

/* custom-media-queries */
@custom-media --narrow-window (max-width: 30em);

@media (--narrow-window) {}

Custom Properties

A syntax for defining custom values accepted by all CSS properties

/* custom-properties */
:root {
--some-length: 32px;

height: var(--some-length);
width: var(--some-length);
}

Custom Selectors

An at-rule for defining aliases that represent selectors

/* custom-selectors */
@custom-selector :--heading h1, h2, h3, h4, h5, h6;

article :--heading + p {}

:dir Directionality Pseudo-Class

A pseudo-class for matching elements based on their directionality

/* dir-pseudo-class */
blockquote:dir(rtl) {
margin-right: 10px;
}

blockquote:dir(ltr) {
margin-left: 10px;
}

Two values syntax for display

Syntax that allows definition of outer and inner displays types for an element

/* display-two-values */
.element {
display: inline flow-root;
display: inline flex;
display: block grid;
}

Double Position Gradients

A syntax for using two positions in a gradient.

/* double-position-gradients */
.pie_chart {
background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
}

Custom Environment Variables

A syntax for using custom values accepted by CSS globally

/* environment-variables */
@media (max-width: env(--brand-small)) {
body {
padding: env(--brand-spacing);
}
}

:focus-visible Focus-Indicated Pseudo-Class

A pseudo-class for matching focused elements that indicate that focus to a user

/* focus-visible-pseudo-class */
:focus:not(:focus-visible) {
outline: 0;
}

:focus-within Focus Container Pseudo-Class

A pseudo-class for matching elements that are either focused or that have focused descendants

/* focus-within-pseudo-class */
form:focus-within {
background: rgba(0, 0, 0, 0.3);
}

Font format() Keywords

A syntax for specifying font format as a keyword in @font-face rule’s format() function

/* font-format-keywords */
@font-face {
src: url(file.woff2) format(woff2);
}

font-variant Property

A property for defining the usage of alternate glyphs in a font

/* font-variant-property */
h2 {
font-variant: small-caps;
}

Gap Properties

Properties for defining gutters within a layout

/* gap-properties */
.grid-1 {
gap: 20px;
}

.grid-2 {
column-gap: 40px;
row-gap: 20px;
}

:has() Relational Pseudo-Class

A pseudo-class for matching ancestor and sibling elements

/* has-pseudo-class */
a:has(> img) {
display: block;
}

Hexadecimal Alpha Notation

A 4 & 8 character hex color notation for specifying the opacity level

/* hexadecimal-alpha-notation */
section {
background-color: #f3f3f3f3;
color: #0003;
}

hwb() Function

A function for specifying colors by hue and then a degree of whiteness and blackness to mix into it

/* hwb-function */
p {
color: hwb(120 44% 50%);
}

ic length unit

Equal to the used advance measure of the "水" (CJK water ideograph, U+6C34) glyph found in the font used to render it

/* ic-unit */
p {
text-indent: 2ic;
}

image-set() Function

A function for specifying image sources based on the user’s resolution

/* image-set-function */
p {
background-image: image-set(
"foo.png" 1x,
"foo-2x.png" 2x,
"foo-print.png" 600dpi
);
}

:is() Matches-Any Pseudo-Class

A pseudo-class for matching elements in a selector list

/* is-pseudo-class */
p:is(:first-child, .special) {
margin-top: 1em;
}

lab() Function

A function for specifying colors expressed in the CIE Lab color space

/* lab-function */
body {
color: lab(80% 50 20);
}

Logical Properties and Values

Flow-relative (left-to-right or right-to-left) properties and values

/* logical-properties-and-values */
span:first-child {
float: inline-start;
margin-inline-start: 10px;
}

Media Query Ranges

A syntax for defining media query ranges using ordinary comparison operators

/* media-query-ranges */
@media (width < 480px) {}

@media (480px <= width < 768px) {}

@media (width >= 768px) {}

Nesting Rules

A syntax for nesting relative rules within rules

/* nesting-rules */
article {
& p {
color: #333;
}
}

:not() Negation List Pseudo-Class

A pseudo-class for ignoring elements in a selector list

/* not-pseudo-class */
p:not(:first-child, .special) {
margin-top: 1em;
}

oklab and oklch color functions

Functions that allow colors to be expressed in OKLab and OKLCH.

/* oklab-function */
p {
color: oklab(72.322% -0.0465 -0.1150);
color: oklch(72.322% 0.12403 247.996);
}

Support for percentages for opacity

Syntactic sugar to use percentages instead of a float between 0 and 1.

/* opacity-percentage */
img {
opacity: 90%;
}

overflow Shorthand Property

A property for defining overflow-x and overflow-y

/* overflow-property */
html {
overflow: hidden auto;
}

overflow-wrap Property

A property for defining whether to insert line breaks within words to prevent overflowing

/* overflow-wrap-property */
p {
overflow-wrap: break-word;
}

Place Properties

Properties for defining alignment within a layout

/* place-properties */
.example {
place-content: flex-end;
place-items: center / space-between;
place-self: flex-start / center;
}

prefers-color-scheme Media Query

A media query to detect if the user has requested the system use a light or dark color theme

/* prefers-color-scheme-query */
body {
background-color: white;
color: black;
}

@media (prefers-color-scheme: dark) {
body {
background-color: black;
color: white;
}
}

rebeccapurple Color

A particularly lovely shade of purple in memory of Rebecca Alison Meyer

/* rebeccapurple-color */
html {
color: rebeccapurple;
}

round(), mod() and rem() functions

The stepped-value functions, round(), mod(), and rem(), all transform a given value according to another "step value", in different ways

/* stepped-value-functions */
div {
left: mod(18px, 5px);
top: rem(18px, 5px);
right: round(2.5px, 1px);
bottom: round(up, 15px, 7px);
}

system-ui Font Family

A generic font used to match the user’s interface

/* system-ui-font-family */
body {
font-family: system-ui;
}

sin(), cos(), tan(), asin(), acos(), atan() and atan2() functions

Functions to calculate varios basic trigonometric relationships

/* trigonometric-functions */
body {
left: sin(45deg);
left: cos(45deg);
left: tan(45deg);
left: asin(0.5);
left: acos(0.5);
left: atan(10);
left: atan2(-1, 1);
}

unset Keyword

The unset CSS keyword resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.

/* unset-value */
div {
border-color: unset;
color: unset;
}