Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validating HTML from the command line

Tags:

I'm a web developer who is increasingly using Vim to code web sites. Are there any HTML validation utilities (or techniques) out there that will take whatever file I'm working on and validate against its DOCTYPE without leaving the shell?

like image 647
Thomas Avatar asked Dec 03 '09 04:12

Thomas


People also ask

How do I validate my HTML code?

In order to validate your code, you have to declare the standard to which it adheres. To describe the HTML standard (the document type declaration, DTD), the file should contain a DOCTYPE declaration (before the HTML code). Here are a few examples (from http://www.htmlhelp.com/tools/validator/doctype.html).

How do I validate HTML and CSS code?

You can validate both HTML and CSS files. You can use any commercial software package or free online application, such as the following World Wide Web Consortium (W3C) validators: W3C CSS Validator at http://jigsaw.w3.org/css-validator/ W3C HTML Validator at http://validator.w3.org/

What tool is used to check HTML validity?

An HTML validator is a quality assurance program used to check Hypertext Markup Language ( HTML ) markup elements for syntax errors. A validator can be a useful tool for an HTML user who receives data electronically from a variety of input sources.


1 Answers

Get yourself tidy from sourceforge and execute it on the shell
tidy -errors -q -f error_file.txt the_file.html

Edit July 2016: The source forge version is outdated (see @phihag's comment). Its successor can be found at http://www.html-tidy.org/ and https://github.com/htacg/tidy-html5.

The History page on ttp://www.html-tidy.org/ states:

In 2015 a group of concerned developers, users, and software integrators formed HTACG with the goal of revitalizing Tidy, which had fallen into a non-maintained state. As a W3C Community Group, HTACG was deemed worthy by the W3C, and W3C passed ownership of their project to HTACG, where it is currently being developed and prepped for a new, stable, and modern release.

like image 77
René Nyffenegger Avatar answered Oct 20 '22 07:10

René Nyffenegger