Skip to main content

W3C Validation

The W3C validation badge performs validation of the HTML, SVG, MathML, ITS, RDFa Lite, XHTML documents. The badge uses the type property of each message found in the messages from the validation results to determine to be an error or warning. The rules are as follows:

  • info: These messages are counted as warnings
  • error: These messages are counted as errors
  • non-document-error: These messages are counted as errors

This badge relies on the https://validator.nu/ service to perform the validation. Please refer to https://about.validator.nu/ for the full documentation and Terms of service. The following are required from the consumer for the badge to function.

  • Path:
    • parser: The parser that is used for validation. This is a passthru value to the service
      • default (This will not pass a parser to the API and make the API choose the parser based on the validated content)
      • html (HTML)
      • xml (XML; don’t load external entities)
      • xmldtd (XML; load external entities)
  • Query string:
    • targetUrl (Required): This is the path for the document to be validated
    • preset (Optional can be left as blank): This is used to determine the schema for the document to be valdiated against. The following are the allowed values
      • HTML, SVG 1.1, MathML 3.0
      • HTML, SVG 1.1, MathML 3.0, ITS 2.0
      • HTML, SVG 1.1, MathML 3.0, RDFa Lite 1.1
      • HTML 4.01 Strict, URL / XHTML 1.0 Strict, URL
      • HTML 4.01 Transitional, URL / XHTML 1.0 Transitional, URL
      • HTML 4.01 Frameset, URL / XHTML 1.0 Frameset, URL
      • XHTML, SVG 1.1, MathML 3.0
      • XHTML, SVG 1.1, MathML 3.0, RDFa Lite 1.1
      • XHTML 1.0 Strict, URL, Ruby, SVG 1.1, MathML 3.0
      • SVG 1.1, URL, XHTML, MathML 3.0

Path Parameters
parser string REQUIRED

Possible values: [default, html, xml, xmldtd]

Example: html
Query Parameters
targetUrl string
Example: https://validator.nu/
preset string
Example: HTML, SVG 1.1, MathML 3.0
style string

One of: flat (default), flat-square, plastic, for-the-badge, social

Example: flat
logo string

One of the named logos (bitcoin, dependabot, gitlab, npm, paypal, serverfault, stackexchange, superuser, telegram, travis) or simple-icons. Simple-icons are referenced using icon slugs which can be found on the simple-icons site or in the slugs.md file in the simple-icons repository.

Example: appveyor
logoColor string

The color of the logo (hex, rgb, rgba, hsl, hsla and css named colors supported). Supported for named logos and Shields logos but not for custom logos. For multicolor Shields logos, the corresponding named logo will be used and colored.

Example: violet
label string

Override the default left-hand-side text (URL-Encoding needed for spaces or special characters!)

Example: healthiness
labelColor string

Background color of the left part (hex, rgb, rgba, hsl, hsla and css named colors supported). The legacy name "colorA" is also supported.

Example: abcdef
color string

Background color of the right part (hex, rgb, rgba, hsl, hsla and css named colors supported). The legacy name "colorB" is also supported.

Example: fedcba
cacheSeconds string

HTTP cache lifetime (rules are applied to infer a default value on a per-badge basis, any values specified below the default will be ignored). The legacy name "maxAge" is also supported.

Example: 3600
link string[]

Specify what clicking on the left/right of a badge should do. Note that this only works when integrating your badge in an <object> HTML tag, but not an <img> tag or a markup language.