CSS nesting, prefixes and cascade: what formatting should preserve
Compare real CSS formatting, minification, prefixes and sorting while retaining shorthand overrides, fallback values and nested-rule positions.
Content reviewed ·
The problem and context
W3C published a CSS Nesting Working Draft on January 22, 2026. Styles that use &, nested media queries and declarations after nested rules need their source positions preserved during cleanup. Choose the CSS syntax used by your target environment, then select prefix queries. The workbench keeps native nesting and displays source and results as text.
Method and calculation
Work through formatting, checking, prefixing, sorting and minifying to inspect each change. Prefix targets are the four displayed legacy browsers or modern defaults. Existing declarations and distinct fallback values remain. Sorting operates within consecutive declaration runs; override families retain their original sequence, with comments, all and nested rules keeping their dividing positions.
Worked example
For .demo{margin-top:12px;margin:0;color:red}, the original top margin is 0. Sorting may move color first while keeping margin-top:12px before margin:0, leaving the margin at 0. Moving margin:0 before margin-top instead makes it 12px. Add user-select:none;user-select:text and choose legacy prefix targets to inspect both fallback values in the prefixed output.
Checklist
Strings containing a b, URLs, custom-property values and necessary calc spaces retain their content, along with /*! comments. Size comparisons use UTF-8 bytes, so formatting or prefixes can produce negative savings. Capacity is 2000000 UTF-16 input units, 50000 nodes, 128 bracket or rule levels and 8000000 output units. Each task has a 30-second limit and can be cancelled.
CSS beautifier and property sorter
CSS input
Input characters: 119
Local processing: up to 2000000 UTF-16 input units, 50000 nodes and 128 bracket/rule levels; output up to 8000000 units, with a 30-second task limit.
Processing options
Chrome 25, Firefox 20, IE 10, Safari 6
Use these tools with this article
- HTML Formatter
Format, minify, check parsing and escape HTML while retaining text, scripts, styles and attribute spelling.
- CSS Formatter
Format, minify, check syntax, prefix and sort CSS with rule statistics and actual UTF-8 size changes.
- CSS Beautifier
Automatically indent CSS, add target-browser prefixes and sort with cascade constraints while preserving strings, variables and nesting.
- XML Formatter
Check XML 1.0 and arrange structural indentation while preserving text, attributes, CDATA and xml:space whitespace.