CssMinifyFormatter Class

Writes a minified CSS text: the whitespace that is not needed is removed, as well as the semicolon of the last declaration of a block. The style sheet is not modified.

public sealed class CssMinifyFormatter : CssFormatter

Remarks

The values of the custom properties are written as is: they are token sequences whose text can be read by scripts. The values that contain a substitution function, such as var(), are kept as specified too: only their whitespace is removed, their numbers and colors are not shortened.

Inheritance
CssFormatter CssMinifyFormatter

Constructors

NameDescription
CssMinifyFormatter()

CssMinifyFormatter()

CssMinifyFormatter.cs
public CssMinifyFormatter()

No documentation is available.

Properties

NameDescription
RemoveEmptyRulesWhether the rules that have no effect are removed: the style rules without declarations (and whose nested rules are removed), and the @media, @supports, @container, @scope and @starting-style rules whose child rules are removed. The empty @layer and @keyframes rules are kept: they declare a layer or replace the keyframes of the same name. The default is true.
RemoveLeadingZerosWhether the leading zero of the numbers of the values is removed (0.5s is written .5s). The default is true.
ShortenColorsWhether the opaque rgb() colors whose components are integers are written in their hexadecimal notation (rgb(255, 0, 0) is written #f00). The default is true.

RemoveEmptyRules

CssMinifyFormatter.cs

Whether the rules that have no effect are removed: the style rules without declarations (and whose nested rules are removed), and the @media, @supports, @container, @scope and @starting-style rules whose child rules are removed. The empty @layer and @keyframes rules are kept: they declare a layer or replace the keyframes of the same name. The default is true.

public bool RemoveEmptyRules { get; init; }

Property value

bool

RemoveLeadingZeros

CssMinifyFormatter.cs

Whether the leading zero of the numbers of the values is removed (0.5s is written .5s). The default is true.

public bool RemoveLeadingZeros { get; init; }

Property value

bool

Whether the opaque rgb() colors whose components are integers are written in their hexadecimal notation (rgb(255, 0, 0) is written #f00). The default is true.

public bool ShortenColors { get; init; }

Property value

bool