Total Validator
HTML / XHTML / WCAG / Section 508 / CSS / Links / Spelling

Help | Website | Feedback

Introduction

Sometimes you may wish to prevent some problems from being reported, and there are two ways of doing this: The first is to specify the problems using the Ignore errors/warnings option. This list of problems applies to all the parts of all the pages that you validate.

Alternatively, you can add special instructions to your pages to ignore specific problems, or even entire types of validations on specific pages or specific parts of those pages. How to do this is described below:

top

(X)HTML pages

Ignoring specific problems

If you wish to ignore specific problems from being reported on specific parts of a web page you can add a 'class' attribute to an existing tag as follows:

<img class="-tv-ignore:E860,E800" src="img.gif" />

The class attribute's value must consist of the keyword '-tv-ignore:' followed by a comma-separated list of the problems to ignore. The listed problems will not be reported on this element and any child elements. Note that depending on the (X)HTML standard you are validating against, there may be restrictions on which elements you are allowed to use the 'class' attribute with.

If you are already using a class attribute then simply add the '-tv-ignore:' class to the existing one:

<img class="myClass -tv-ignore:E860" src="img.gif" />

Alternatively you could wrap the existing markup with a <div> or <span> instead:

<div class="-tv-ignore:E860">
  <img class="myClass" src="img.gif" />
</div>

You can also nest the problems to ignore. In the following example problem, E860 will not be reported for any of the markup between (and including) the <div> tags, E800 will not be reported for the first set of <p> and <img> tags, but could be reported for the second set.

<div class="-tv-ignore:E860">
  <p class="-tv-ignore:E800">
    <img src="img.gif" />
  </p>
  <p>
    <img src="img.gif" />
  </p>
</div>

You can use this system to ignore whole sections of a page, or the whole page, (with HTML5 you can add a 'class' attribute to the <html> tag). Or you could prevent single words or phrases from being spell checked as follows:

<p>Mary had a <span class="-tv-ignore:E031">lickle</span> lamb, its fleece
was <span class="-tv-ignore:E031">wite</span> as snow.<p>

If the problem you specify does not apply to your markup, there is no harm, it will simply be ignored. In the examples above you may have noticed that E860 and E800 are actually mutually exclusive as they apply to WCAG 1.0 and WCAG 2.0 respectively.

Note that when you specify a problem to ignore, the validation is still performed, but the problem is not reported. This also occurs when using the Ignore errors/warnings option. So if you wished to ignore a E404 error on a broken link, an attempt would still be made to check the link first, slowing down the validation process:

<a class="-tv-ignore:E404" href="a_bad_page.html">

It would be better not to test the link at all, and you can do this as described in the next section.

top

Ignoring all problems for a specific type of validation

Depending on your requirements, it may be more efficient to prevent an entire type of validation being carried out on a section of markup. For this purpose there are five special 'class' attribute values you can use:

  • -tv-ignore-html
  • -tv-ignore-access
  • -tv-ignore-links
  • -tv-ignore-spellcheck
  • -tv-ignore-css

For example, the following prevents accessibility testing on the enclosed markup (including the <div> tags):

<div class="-tv-ignore-access">
  <p>
    <img src="img.gif" />
  </p>
</div>

Because the 'class' attribute is a white-space separated list of class names, you can specify more than one of these special values at a time and mix them with problem specific values:

<div class="myClass -tv-ignore-links -tv-ignore:E860,E800 -tv-ignore-access">
  <img src="img.gif" />
  <a href="a_bad_page.html">
</div>

Note that the special values such as '-tv-ignore-access', take precedence over any individual problem exclusions like E860.

As mentioned in the previous section, using '-tv-ignore-links' will prevent any of the enclosed links from being tested. Also if a link appears in more than one place, you must put the ignore request at the first place TV will find the link, or on all instances of the link, otherwise TV will test the first one it finds.

top

CSS

As described above you can use the 'class' attribute to ignore CSS problems with any CSS used in 'style' attributes or <style> tags. Alternatively, there is a system specifically for use with CSS in style sheets, which can also be used within <style> tags, as described below:

Using at-rules to ignore problems in CSS

If you wish to ignore specific problems from being reported on a specific part of your style sheet you can add special at-rules as follows:

@-tv-ignore start E777,W776;

h1 { -moz-color: firefox; }
h2 { -moz-color: thunderbird; }

@-tv-ignore end E777,W776;

In this case the problems E777 and W776 will not be reported for any of the statements that are enclosed by the 'start' and 'end' rules. As with HTML you can also ignore all CSS or Links problems, as well as specific ones. The general form of the at-rule is as follows:

@-tv-ignore [ start | end ] [[ all-css | all-links ] || [ Exxx [,Exxx]* ]];

This is completely safe to add to your style sheet because all user agents, such as browsers, will completely ignore any rules they do not recognise.

You can use these rules as many times as you wish, you can nest them, and start/end the exclusion of individual problems:

@-tv-ignore start all-css W776;

h1 { -moz-color: firefox; }

@-tv-ignore end all-css;

h2 { -moz-color: firefox; }

@-tv-ignore end W776;

In the example above, the h1 declaration will not report any problems because 'start all-css' prevents any CSS validation. The 'end all-css' at-rule allows CSS validation again, but the W776 restriction is still in force, and so the 'h2' declaration does not reports a W776 problem.

The 'start' at-rules apply until there is a corresponding 'end' rule. So if you forget to specify the 'end' rule then the rule will apply to the end of the style sheet. If you uses them within style elements, they will also apply across different style elements. But the rules are never inherited by any imported style sheets, and if you try to 'end' something you have not started, it will be silently ignored.

top

Using a property to ignore problems in CSS

In addition to using an at-rule to ignore problems as described above, there is a corresponding property that you can use:

h1 {
  color: red;
  -tv-ignore: start E777,W776;
  -moz-color: firefox;
  -tv-ignore: end W776;
  -moz-color: firefox;
  -tv-ignore: end E777;
}
h2 { -moz-color: firefox; }

Just as with the at-rule exclusions defined using this property apply from the 'start' to the 'end'. They are not restricted to the block in which they are defined, but apply to all statements between the 'start' and 'end'.

The general form of this property is almost identical to the at-rule and operates in the same way:

-tv-ignore [ start | end ] [[ all-css | all-links ] || [ Exxx [,Exxx]* ]];

You can mix the property with the at-rule if you wish. Here is a complex example of this:

1  @-tv-ignore start E777,W776;
2  h1 {
3    -moz-color: firefox;
4    -tv-ignore: end E777;
5    -moz-color: firefox;
6    -tv-ignore: end W776;
7    -tv-ignore: start E725;
8  }
9  @import "test.css";
10 h2 { -moz-color:fred; }

No problems are reported for the '-moz-color' property on line 3, due to the at-rule on line 1. Only W776 is reported for the '-moz-color' on line 5 because of the 'end' property on line 4. The 'end' properties on lines 4 and 6, mean that both E777 and W776 are reported on line 10. Finally the property on line 7 prevents E725 on line 9.

top

Parsing problems

There are certain type of validation problem that you may not be able to ignore. Generally, you will not be able to use the above system to mask any parsing problems. This includes certain CSS validation problems, which are generated when the CSS is parsed.

Although we expect to reduce the number of parsing problems that are currently ignored, many will remain impossible to ignore because by definition a parsing problem means that Total Validator cannot properly understand the markup/css that is being used and so cannot deal with it properly. But this also applies to any user agent trying to read your pages, and so it is essential that you correct such parsing problems before publishing your pages.

top