CSSTIDY(1)
π CSSTIDY β the manual page, but make it make sense π
okay bestie, so csstidy(1)?? it's a CSS parser and optimiser. that's the whole vibe. it eats your CSS, chews it up, and spits out something smaller and shinier. let's get into it π
β¨ SYNOPSIS β¨
csstidy input-file [options] [output-file]
πΈ DESCRIPTION πΈ
so the csstidy(1) command parses and optimises a css file that you hand it as input-file. if you don't give it an output-file, it just dumps the results to standard output, no big deal. and there are so many options for fine-grained control over readability, file size, and other lil items. it's giving customizable fr fr.
if you use the filename -, csstidy reads from stdin. iconic behaviour honestly.
in most cases you'll probably find that csstidy's defaults are reasonable and applicable to most situations. like, just let it cook π
heads up bestie: csstidy is not designed to be a css validator. although you should only enter valid (or rather well-formed) code, csstidy will also parse and fix incorrect code. so it's less "hall monitor" and more "chill friend who cleans up after you" π
π¦ EXAMPLES π¦
to optimise a CSS file and send the output to screen, use:
csstidy mycssfile.css
if you want to save the output to a file, use:
csstidy mycssfile.css myoutputfile.css
if you want to use an option[s] and output to a file, use:
csstidy mycssfile.css --lowercase_s=true myoutputfile.css
π OPTIONS π
look at all these knobs and dials. yes we're going through every single one. no skipping. periodt.
--allow_html_in_templates=[false|true]β default =false.--case_properties=[false|true]β the case for properties. default =false.--compress_colors=[true|false]β if you set this totrue, csstidy will optimize color value by trying to save bytes (i.e.blackbecomes#000). default =true.--compress_font-weight=[true|false]β if you set this totrue, csstidy will optimize font value by trying to save bytes (i.e.normalbecomes400). default =true.--discard_invalid_properties=[false|true]β if you set this totrue, csstidy will remove invalid properties. in a sense this is like validation, except you get no warnings unless you study the output. like, as an example, if you misspelled the propertywidthaswith, that property will simply be removed. gone. bye. default =false.--lowercase_s=[false|true]β if you set this totrue, all uppercase selectors (i.e.A,P,SPAN) will be rewritten in lowercase. default =false.--preserve_css=[false|true]β all comments and most browser specific hacks will be removed if this is set tofalse. setting this totruewill preserve browser specific hacks. default =false.--remove_bslash=[true|false]β remove unnecessary backslashes. this may or may not be desirable depending upon whether you have used backslashes to accommodate browsers that do not comply with w3c standards. default =true.--remove_last_;=[false|true]β default =false.--silent=[false|true]β when set totrue, csstidy will not output information about the optimizations preformed. default =false.--sort_properties=[false|true]β sorts properties (i.e.background,color,width) of selectors. default =false.--sort_selectors=[false|true]β sorts selectors. use this with caution, as it will totally rearrange any sense of layout in your file that you may have written into it, and css is sensitive to order. it sorts in order of ID's, classes and then selectors. default =false.--timestamp=[false|true]β if set totrue, adds a comment enclosed timestamp to the top of the output. default =false.--merge_selectors=[2|1|0]β if selectors (including ID's and classes) have identical properties, then csstidy will merge them. a setting of2represents a high degree of merging.0represents no merging. default =2.--optimise_shorthands=[1|2|0]β if set to2, csstidy will invoke all optimisations.0represents no optimisations, and1a safe level of optimatisations. default =1.--template=[default|filename|low|high|highest]β affects how much whitespace is removed and ultimately the readability of the output.
π CSS HACKS π
okay so here's the list of all CSS hacks that will not be modified by default by csstidy. if you enable preserve CSS, more hacks will be saved. in general you should do without CSS hacks anyway, but if you need them and want to use csstidy you should use one of the following hacks:
p\roperty:value; (only if you disable the removal of unnecessary backslashes)
div#test
head:first-child+body div
body>div
html[xmlns] div
@import "null?\"\\{"; @import "styles.css"; (and all other @import rules)
@media all{/\* rules \*/}
* html div
i\{content:"\"/*"\} div\{property:value\}
html*#test
_property:value
π«Ά AUTHOR π«Ά
written by Florian Schmitz <floele@gmail.com> β shoutout to the legend π
π RESOURCES π
main web site: http://csstidy.sourceforge.net/
this manual page was written by Kevin Coyner <kcoyner@debian.org> for the Debian project but may be used by others. so generous of them honestly π
and that's the whole page bestie!! this version is dated 03/18/2007 and lives under the name CSSTIDY(1) in the manual. go forth and optimise your CSS, you main character π§β¨π
π¦ where this page comes from
- debian bookworm: csstidy 1.4-7 Β· GPL-2.0-only
- debian trixie: csstidy 1.4-8 Β· GPL-2.0-only
- ubuntu jammy: csstidy 1.4-6build1 Β· GPL-2.0-only
- ubuntu noble: csstidy 1.4-7 Β· GPL-2.0-only
- ubuntu questing: csstidy 1.4-8
- ubuntu resolute: csstidy 1.4-9 Β· GPL-2.0-only
- ubuntu stonking: csstidy 1.4-9 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms