hanshq.net

Validating HTML and CSS with curl
(16 March 2014)

The World Wide Web Consortium (W3C) provide automatic validation tools for HTML and CSS. Sometimes it's handy to be able to validate a web page or style cheet from the command line. Here is a way to do it with curl:

HTML

This is how I validate my HTML files with curl:

$ curl --form "uploaded_file=@file.html;type=text/html" --silent \
               --show-error http://validator.w3.org/check | grep -q '[Valid]'

CSS

and CSS:

$ curl --form "file=@file.css;type=text/css" --silent --show-error \
               http://jigsaw.w3.org/css-validator/validator | \
               grep -q 'Congratulations! No Error Found.'