HOW TO: Ignore specified HTML segments/sections in documents

For technical support and bug reports for all editions of CSS HTML Validator, including htmlval for Linux and Mac.
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

HOW TO: Ignore specified HTML segments/sections in documents

Post by Albert Wiersch »

Here's a little "trick" that most people aren't aware of. If you have a certain part or section of an HTML or XHTML document that you want CSS HTML Validator to ignore, then you can enclose it in "chvignore" comments.

Example:

Code: Select all

<!--chvignore-->bad HTML here<!--/chvignore-->
NOTE: This works only with CSS HTML Validator's own validator engine. HTML Tidy, nsgmls, JavaScript Lint, PHP, etc will not understand these special comments.

If using JavaScript Lint for JavaScript checking, then you can use this to ignore part of a document:

Code: Select all

/*jsl:ignore*/
(code that fires warnings)
/*jsl:end*/
For more information (JavaScript Lint):
https://www.javascriptlint.com/docs/
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
RSteinwand
Rank VI - Professional
Posts: 596
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

Re: HOW TO: Ignore specified HTML segments/sections in documents

Post by RSteinwand »

Hi Albert,

I still get a HTML Tidy warning with this:
<!--cseignore-->
<link type="text/css" media="all" href="/css/<%= InsertCSS() %>" rel="stylesheet" />
<!--/cseignore-->

... and get a Javascript SyntaxError with this:
<!--cseignore-->
<div id="nav"><script type="text/javascript"><%= InsertMenu() %></script></div>
<!--/cseignore-->

If you have code to comment out the non-CSE parts (like HTML Tidy or nsgmls), maybe you can add that to this thread as well?
Rick
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: HOW TO: Ignore specified HTML segments/sections in documents

Post by Albert Wiersch »

Thanks Rick, I've added this:
NOTE: This works only with CSS HTML Validator's own validator engine. HTML Tidy, nsgmls, JavaScript Lint, PHP, etc will not understand these special tags and comments.

I've also added information about ignoring part of a document with JavaScript Lint. I don't believe the other checkers support ignoring parts of a document.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
roedygr
Rank V - Professional
Posts: 367
Joined: Fri Feb 17, 2006 5:22 am
Location: Victoria BC Canada

Re: HOW TO: Ignore specified HTML segments/sections in documents

Post by roedygr »

There is a catch. cseignore will not let you get away with high bit characters.
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: HOW TO: Ignore specified HTML segments/sections in documents

Post by Albert Wiersch »

roedygr wrote:There is a catch. cseignore will not let you get away with high bit characters.
True. I've added this to the documentation:
NOTE: Does not ignore "high ASCII characters" for the "high ASCII" character check, if enabled.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial