CSS HTML Validator - The fast, all-in-one, HTML, CSS, Link, SEO, spelling, and accessibility checker for Windows, & htmlval for Mac and Linux
Home htmlval Documentation

Documentation for htmlval for Linux and Mac

Use the new command line (console) tool htmlval to check HTML, CSS, and JSON documents on Linux and Mac. This program is based on the core validation engine in CSS HTML Validator for Windows, which was ported to Linux and Mac.

Note that some features like link checking, spell checking, PHP syntax checking, JavaScript checking, and some other features are currently not available in the htmlval port. This is a command line tool for Linux and Mac; there is no GUI like in the Windows version.

Download htmlval FREE Limited Version

FREE limited version: htmlval for Linux Free Limited (v23.04)

Download htmlval for Linux FREE Limited VersionHow to Install

FREE limited version (arm64/M1/M2/Mx): htmlval for Apple Mac (ARM) Free Limited (v23.04)

Download htmlval for Mac (ARM) FREE Limited VersionHow to Install

FREE limited version (Intel/x86_64): htmlval for Apple Mac (Intel) Free Limited (v23.04)

Download htmlval for Mac (Intel) FREE Limited VersionHow to Install

The FREE limited version of htmlval is fully functional (with no time limit) except for the maximum number of errors and warnings being locked (limited) to 10 each. The FREE limited version is also considered to be the trial version (but it has no time limit).

About htmlval for Linux and Mac

For specific information (such as download, install, and uninstall info) about htmlval for Linux or htmlval for Mac, please see the htmlval for Linux or htmlval for Mac page.

[ To the top ]

Help and Version Information

Use --help (or -H) or --version (or -V) to get a quick summary of commands or the version information and copyright notice.

$ htmlval --help

Example output for help
$ htmlval --help
Usage: htmlval [OPTION]... [FILE]...

Validation control:
  -a, --access              turn on accessibility checking (default off)
      --cfg [FILE]          specify a cfg file (overrides default cfg file)
  -C, --css                 document is CSS (force CSS syntax checking)
      --nocss               turn off CSS checking in HTML (default on)
  -m, --nomobile            turn off mobile messages (default on)
  -u, --nosecurity          turn off security messages (default on)
  -S, --noseo               turn off SEO/search engine messages (default on)
  -q  --reqquotes           require all attribute values be quoted
      --std                 standards-compliant check
      --strictamp           require strict ampersand encoding (default off)
      --uf [FILE]           specify a user functions file
      --uf2 [FILE]          specify a 2nd user functions file
      --wcag2=NUM           set WCAG2 conformance level 1-3 or 0 for off

Output control:
  -e, --errorsonly          show errors only
  -w, --errwarnonly         show errors and warnings only (default)
      --format [FORMAT]     set message format (for -l; see documentation)
  -f, --full                full validation (all message types)
  -j, --json                output messages in JSON format
      --linelen=NUM         max line length (for -n)
  -l, --listonly            output messages in list format
      --maxerr=NUM          set maximum number of errors before aborting
      --maxwarn=NUM         set maximum number of warnings before aborting
  -c, --nocomments          no comment messages (with some exceptions)
  -h, --noheader            no file header (i.e. File X of Y)
      --nomsgid=ID1,ID2     disable messages by message ID number
  -r, --noregular           no regular messages (with some exceptions)
  -n, --normal              normal output format (default)
  -t, --tree[=c]            show HTML structure tree, use =c for compact
  -s, --short               shorten messages (disables extended messages)
      --veo [FILE]          specify a veo file (validator engine options)
  -v, --verbose             verbose messages (extended messages) (default)
  -x, --xml                 output messages in XML format

Miscellaneous:
  -V, --version             display version information and exit
  -H, --help                display this help text and exit

htmlval for Linux does not support all the features of the Windows version.

$ htmlval --version

Example output for version
$ htmlval --version
CSS HTML Validator Pro 2023/v23.0200 Command Line Processor for Linux
Copyright (C) 1997-2023 AI Internet Solutions LLC
https://www.htmlvalidator.com/

[ To the top ]

Validating Documents

To validate a document, simply use htmlval and provide it the path to the document to validate. You can validate/check HTML, CSS, and JSON documents.

$ htmlval document.html $ htmlval styles.css

Example output for document.html validation
$ htmlval document.html
==================================
=== File 1 of 1: document.html ===
==================================

CSS HTML Validator Pro v23.0200 on Linux (Registered)
Checking "document.html" (92 characters).
Checked on 2023-05-29 at 20:44:55.

     Number of lines checked: 5 in 0.00 seconds
 Number of lines in document: 5 (100.0% of lines checked)
     Number of lines ignored: 0
Number of character entities: 0
        Number of start tags: 6
          Number of end tags: 3 (50.0% of start tags with end tags)
Number of <% ... %> sections: 0
     Number of HTML comments: 0

Number of validator comments: 1
          Number of messages: 0
            Number of errors: 4 (first in line 3)
          Number of warnings: 1 (first in line 2)

--------------------------------------------------

   2: <html>
-------||||

[CHV] Warning number 1 in line 2:2:
The natural primary language is not specified. It is strongly
recommended that the "lang" attribute be used with the <html> element
to specify the primary language. For example, add the attribute
lang="en" for English or lang="fr" for French. Specifying the language
assists braille translation software, speech synthesizers, translation
software, and has other benefits.

   3: <h1>What's up?</h1>
-------||

[CHV] Error number 1 in line 3:2:
The viewport property was not defined. The viewport property tells
browsers how to adjust the page's dimensions and scaling for the
screen size. Google considers this a mobile usability error. Visit
https://web.dev/responsive-web-design-basics/ for more information.

   3: <h1>What's up?</h1>
-------||

[CHV] Error number 2 in line 3:2:
Missing <title> element. Add an explicit <head> section with a <title>
element to give this page a title. Exceptions (when <title> can be
omitted): 1) "iframe srcdoc" documents, and 2) if the title is
provided by a higher-level protocol (like the subject line of an
e-mail message when HTML is used as the email format).

   4: <p style="coloor: blue">test</p>
----------------||||||

[CHV] Error number 3 in line 4:11:
The "coloor" property is not a recognized property. Should this
property be "color"?

   5: <sdfsdsfd>
-------||||||||

[CHV] Error number 4 in line 5:2:
The <sdfsdsfd> element is not valid. Is it misspelled?

[CHV] Comment number 1:
"Errors and warnings only" mode enabled. Showing only error and
warning messages (with some exceptions).

--------------------------------------------------

$ htmlval data.json

Example output for data.json validation
$ htmlval data.json
==============================
=== File 1 of 1: test.json ===
==============================

CSS HTML Validator Pro v23.0210 on Linux (Registered)
Checking "test.json" (2085 characters).
Checked on 2023-05-30 at 15:16:37.

     Number of lines checked: 88 in 0.00 seconds
 Number of lines in document: 88 (100.0% of lines checked)
     Number of lines ignored: 0

Number of validator comments: 1
          Number of messages: 0
            Number of errors: 1 (first in line 37)
          Number of warnings: 0

--------------------------------------------------

  37: "messagenumber"::2,
----------------------|

[CHV] Error number 1 in line 37:17:
Expected a valid JSON value here, like 'false', 'null', 'true', or an
array, number, object, or string. Is this a misplaced or extra colon?

[CHV] Comment number 1:
JSON detected.

--------------------------------------------------

You can also specify more than one document to validate.

$ htmlval document.html styles.css

JSON Lines and NDJSON syntax checking is also supported. Ensure that the filename has a file extension of jsonl for JSON Lines or ndjson file extension for NDJSON for automatic detection of these file types.

$ htmlval data.jsonl $ htmlval data.ndjson

[ To the top ]

Validation Control

There are several options to control the validation scope. These include (but are not limited to):

For example, to validate a document with accessibility checking enabled:

$ htmlval -a document.html

To set the WCAG2/2.1 conformance level to 3, you can use (using --wcag2=NUM automatically turns on accessibility checking so also using -a is not needed):

$ htmlval --wcag2=3 document.html

[ To the top ]

Message Output Control

By default, only error and warning messages are shown (with some exceptions). If you want to see only error messages then you can use the -e or --errorsonly option. If you want a full validation with all validator messages, you can use the -f or --full option.

$ htmlval -e document.html $ htmlval --full document.html

If you want shorter (terse) validator messages, then you can use the -s or --short option. This option is good for more experienced developers who don't need all the details provided in the longer, extended messages.

$ htmlval -s document.html

If you want shorter (terse) validator messages and only error messages, then you can combine the -s and -e options together like this:

$ htmlval -es document.html

If you want the validator messages in a simple list, then you can use the -l or --list option. You can optionally use the --format option to control the message format (see the XML Message Format Variables help topic for more information). The default message format is: %Type%%where2%: %category2%%msgtext%.

$ htmlval -l document.html

Example output for document.html validation with list option (-l)
$ htmlval -l document.html
==================================
=== File 1 of 1: document.html ===
==================================

Warning (line 2, col 2): The natural primary language is not specified. It is strongly recommended that the "lang" attribute be used with the <html> element to specify the primary language. For example, add the attribute lang="en" for English or lang="fr" for French. Specifying the language assists braille translation software, speech synthesizers, translation software, and has other benefits.

Error (line 3, col 2): (Grouped->Mobile) The viewport property was not defined. The viewport property tells browsers how to adjust the page's dimensions and scaling for the screen size. Google considers this a mobile usability error. Visit https://web.dev/responsive-web-design-basics/ for more information.

Error (line 3, col 2): Missing <title> element. Add an explicit <head> section with a <title> element to give this page a title. Exceptions (when <title> can be omitted): 1) "iframe srcdoc" documents, and 2) if the title is provided by a higher-level protocol (like the subject line of an e-mail message when HTML is used as the email format).

Error (line 4, col 11): (Styles->General) The "coloor" property is not a recognized property. Should this property be "color"?

Error (line 5, col 2): The <sdfsdsfd> element is not valid. Is it misspelled?

Comment: "Errors and warnings only" mode enabled. Showing only error and warning messages (with some exceptions).

Comment: Results by CSS HTML Validator Pro 2023/v23.0200 - https://www.htmlvalidator.com/ .
Example output for document.html validation with errorsonly, short, and list options (-esl)
$ htmlval -esl document.html
==================================
=== File 1 of 1: document.html ===
==================================

Error (line 3, col 2): (Grouped->Mobile) The viewport property was not defined.

Error (line 3, col 2): Missing <title> element. Add an explicit <head> section with a <title> element to give this page a title.

Error (line 4, col 11): (Styles->General) The "coloor" property is not a recognized property. Should this property be "color"?

Error (line 5, col 2): The <sdfsdsfd> element is not valid. Is it misspelled?

Comment: "Errors only" mode enabled.

Comment: Results by CSS HTML Validator Pro 2023/v23.0200 - https://www.htmlvalidator.com/ .

Many (but not all) validator messages have a unique message ID. If you know the message ID of a validator message that you don't want to see, then you can disable the message using the --nomsgid option. Just set it to a comma-separated list of message IDs that you want to disable.

$ htmlval --nomsgid=2022123456,2022123457 document.html

Note that you can combine multiple single letter options that begin with a single dash. For example, you can combine -e, -m, and -s into -ems. Commands that begin with two dashes (i.e. --errorsonly, --nomobile, --short, etc.) cannot be combined in the same way.

[ To the top ]

JSON and XML Output

Use the -j or --json option to get the validator messages in JSON.

$ htmlval -j document.html

Example output for document.html validation with JSON output
$ htmlval -j document.html
{
"validator":"CSS HTML Validator Professional on Linux",
"version":"2023",
"registered":"YES",
"filename":"document.html",
"bytesize":92,
"charsize":92,
"lineschecked":5,
"percentlineschecked":100.0,
"linesinfile":5,
"linesignored":0,
"numberofentities":0,
"numberoftagnames":6,
"numberofclosingtags":3,
"percentclosed":50.0,
"serversections":0,
"numberofhtmlcomments":0,
"numberofvalidatorcomments":2,
"numberofmessages":0,
"numberoferrors":4,
"numberofwarnings":1,
"maxmessagechars":371,
"messages":[
{
"messagetype":"WARNING",
"messagenumber":1,
"messageflags":0,
"messageid":2011111500,
"linenumber":2,
"charlocation":2,
"charlocationlength":4,
"message":"The natural primary language is not specified. It is strongly recommended that the \"lang\" attribute be used with the <html> element to specify the primary language. For example, add the attribute lang=\"en\" for English or lang=\"fr\" for French. Specifying the language assists braille translation software, speech synthesizers, translation software, and has other benefits."
}
,{
"messagetype":"ERROR",
"messagecategory":"Mobile",
"messagenumber":2,
"messageflags":0,
"messageid":2021070901,
"linenumber":3,
"charlocation":2,
"charlocationlength":2,
"message":"The viewport property was not defined. The viewport property tells browsers how to adjust the page's dimensions and scaling for the screen size. Google considers this a mobile usability error. Visit https:\/\/web.dev\/responsive-web-design-basics\/ for more information."
}
,{
"messagetype":"ERROR",
"messagenumber":1,
"messageflags":0,
"messageid":2021092901,
"linenumber":3,
"charlocation":2,
"charlocationlength":2,
"message":"Missing <title> element. Add an explicit <head> section with a <title> element to give this page a title. Exceptions (when <title> can be omitted): 1) \"iframe srcdoc\" documents, and 2) if the title is provided by a higher-level protocol (like the subject line of an e-mail message when HTML is used as the email format)."
}
,{
"messagetype":"ERROR",
"messagecategory":"General",
"messagenumber":4,
"messageflags":1,
"linenumber":4,
"charlocation":11,
"charlocationlength":6,
"message":"The \"coloor\" property is not a recognized property. Should this property be \"color\"?"
}
,{
"messagetype":"ERROR",
"messagenumber":3,
"messageflags":0,
"linenumber":5,
"charlocation":2,
"charlocationlength":8,
"message":"The <sdfsdsfd> element is not valid. Is it misspelled?"
}
,{
"messagetype":"COMMENT",
"messagenumber":1,
"messageflags":0,
"messageid":2002071603,
"message":"\"Errors and warnings only\" mode enabled. Showing only error and warning messages (with some exceptions)."
}
,{
"messagetype":"COMMENT",
"messagenumber":2,
"messageflags":0,
"message":"Results by CSS HTML Validator Pro 2023\/v23.0200 - https:\/\/www.htmlvalidator.com\/ ."
}
]
}

You can redirect the JSON to a file like this:

$ htmlval -j document.html >output.json

Similarly, you can use the -x or --xml option to get the validator messages in XML.

$ htmlval --xml document.html

Example output for document.html validation with XML output
$ htmlval --xml document.html
<?xml version="1.0"?>
<documentlist generator="CSS HTML Validator Professional" generatorversion="2023" generateddate="2023-05-29" generatedtime="21:12:58" registered="1">
 <document location="document.html" lines="5" bytes="92">
  <messagelist errors="4" warnings="1" messages="0" comments="2">
   <message type="warning" category="" group="normal" msgid="2011111500" linenum="2" charnum="2" charlength="4">The natural primary language is not specified. It is strongly recommended that the "lang" attribute be used with the <html> element to specify the primary language. For example, add the attribute lang="en" for English or lang="fr" for French. Specifying the language assists braille translation software, speech synthesizers, translation software, and has other benefits.</message>
   <message type="error" category="Mobile" group="normal" msgid="2021070901" linenum="3" charnum="2" charlength="2">The viewport property was not defined. The viewport property tells browsers how to adjust the page's dimensions and scaling for the screen size. Google considers this a mobile usability error. Visit https://web.dev/responsive-web-design-basics/ for more information.</message>
   <message type="error" category="" group="normal" msgid="2021092901" linenum="3" charnum="2" charlength="2">Missing <title> element. Add an explicit <head> section with a <title> element to give this page a title. Exceptions (when <title> can be omitted): 1) "iframe srcdoc" documents, and 2) if the title is provided by a higher-level protocol (like the subject line of an e-mail message when HTML is used as the email format).</message>
   <message type="error" category="General" group="css" msgid="-1" linenum="4" charnum="11" charlength="6">The "coloor" property is not a recognized property. Should this property be "color"?</message>
   <message type="error" category="" group="normal" msgid="-1" linenum="5" charnum="2" charlength="8">The <sdfsdsfd> element is not valid. Is it misspelled?</message>
   <message type="comment" category="" group="normal" msgid="2002071603" linenum="-1" charnum="-1" charlength="-1">"Errors and warnings only" mode enabled. Showing only error and warning messages (with some exceptions).</message>
   <message type="comment" category="" group="normal" msgid="-1" linenum="-1" charnum="-1" charlength="-1">Results by CSS HTML Validator Pro 2023/v23.0200 - https://www.htmlvalidator.com/ .</message>
  </messagelist>
 </document>
</documentlist>

[ To the top ]

Validating http/https URLs

If you have curl then you can use it to validate URLs by piping the output of curl to htmlval.

$ curl https://mywebsite.com | htmlval

[ To the top ]

Using .veo Files

A .veo file is an export of validator options from the Validator Engine Options in the Windows version. This file can be used with htmlval. Note that options in the .veo file will override options on the command line, and not all options supported by the Windows version are supported by htmlval (unsupported options will be ignored).

$ htmlval --veo ./path/myveofile.veo document.html

[ To the top ]

User Function Files (Advanced)

You can use the same user function files that CSS HTML Validator for Windows uses by specifying one or two user function files with the --uf and --uf2 options. User function files allow for advanced customization of the validation and its output. Visit the TNPL scripting help topic for more information.

Add the --danger option (only if needed) to enable potentially dangerous TNPL functions like writeFile() and deleteFile().

$ htmlval --uf ./path/myuserfunctions.txt document.html

[ To the top ]

About the cfg File (Advanced)

The cfg file (i.e. htmlvalV230.cfg) is required and is the same file used in the Windows version. It's a binary file and is not user-editable except by using the Configuration Editor in the Windows version. However, we do not recommend editing this file, but if you want to edit it anyway then you could do so using the Windows version.

The edited cfg file could then be used with htmlval to override the default file (i.e. htmlvalV230.cfg). You can specify the config file for htmlval to use with the --cfg [FILE] option.

$ htmlval --cfg ./path/myconfig.cfg document.html

[ To the top ]

Buy a License for htmlval for Mac and Linux

If you like what you see and would like to buy a license and support continued development of htmlval, then you can buy a license for CSS HTML Validator Pro for Windows or CSS HTML Validator Enterprise for Windows. These editions include htmlval. Note that htmlval is not included with the Home edition.

You can also buy an htmlval-only license for $79 which includes only the command line (console) tool for both Linux and Mac. IMPORTANT: This htmlval-only license does not include the Windows GUI app.

[ To the top ]