Validate HTML on local machine

随声附和 提交于 2019-12-02 20:08:51

You can download a vnu.jar release for checking HTML5 documents offline. See https://github.com/validator/validator/releases/latest for the actual download file, and see https://validator.github.io/validator/ for more information

If you're using firefox, this plugin is perfect:

http://users.skynet.be/mgueury/mozilla/

I use it all day. When you view source it shows you a list of errors and highlights them for you.

A command line tool for validating a folder of html files: https://github.com/svenkreiss/html5validator

It integrates with CircleCI and TravisCI and can be used for validating Pelican and Jekyll sites.

Perhaps the most straightforward way to do this, is the way I do it all the time. "View source" of the web page, select it all (ctrl+a), choose "copy" (crtl+c), tab over to the validator, and its "direct input" option, and paste it in (ctrl+v). Easy, peasy.

On Mac, install w3validator by homebrew brew install vnu. Then check your local site by vnu http://localhost/site or any local file by vnu path/to/your/file.html (From Bluu answer)

If you're using node you may use package html-validator

const validator = require('html-validator')
const fs = require('fs')
var options = {
  format: 'text'
}

fs.readFile( 'file-to-validate.html', 'utf8', (err, html) => {
  if (err) {
    throw err;
  }

  options.data = html

  validator(options)
    .then((data) => {
      console.log(data)
    })
    .catch((error) => {
      console.error(error)
    })
})

http://validator.w3.org/#validate_by_upload if you don't mind uploading the HTML source file.

http://getfirebug.com/ if you're running Firefox can help with HTML validation issues as well.

if you have internet connection and want to use https://validator.w3.org/ for localhost without installing, you can use ngrok

reference : https://academy.byidmore.com/post/W3C-Markup-Validation-for-Localhost-5bc942eb3704302c0986bd60

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!