Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic W3C Validation

I have a small element on my website that displays the validity of the current page's markup. At the moment, it is statically set as "HTML5 Valid", as I constantly check whether it is, in fact, HTML5 valid. If it's not then I fix any issues so it stays HTML5-valid.

I would like this element to be dynamic, though. So, is there any way to ping the W3C Validation Service with the current URL, receive the result and then plug the result into a PHP or JavaScript function? Does the W3C offer an API for this or do you have to manually code this?

like image 856
mythofechelon Avatar asked Aug 10 '26 19:08

mythofechelon


1 Answers

Maintainer of the W3C HTML Checker (aka validator) here. In fact the checker does expose an API that lets you do, for example:

https://validator.w3.org/nu/?doc=https%3A%2F%2Fgoogle.com%2F&out=json

…which gives you the results back as JSON. There’s also a POST interface.

You can find more details here:

  • https://github.com/validator/validator/wiki/Service-»-HTTP-interface
  • https://github.com/validator/validator/wiki/Service-»-Input-»-POST-body
  • https://github.com/validator/validator/wiki/Service-»-Input-»-GET
  • https://github.com/validator/validator/wiki/Output-»-JSON
like image 173
sideshowbarker Avatar answered Aug 12 '26 09:08

sideshowbarker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!