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 to true, csstidy will optimize color value by trying to save bytes (i.e. black becomes #000). default = true.
  • --compress_font-weight=[true|false] β€” if you set this to true, csstidy will optimize font value by trying to save bytes (i.e. normal becomes 400). default = true.
  • --discard_invalid_properties=[false|true] β€” if you set this to true, 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 property width as with, that property will simply be removed. gone. bye. default = false.
  • --lowercase_s=[false|true] β€” if you set this to true, 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 to false. setting this to true will 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 to true, 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 to true, 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 of 2 represents a high degree of merging. 0 represents no merging. default = 2.
  • --optimise_shorthands=[1|2|0] β€” if set to 2, csstidy will invoke all optimisations. 0 represents no optimisations, and 1 a 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 πŸ§šβœ¨πŸ’–