Jump to content

Help:Markup validation

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Eubulides (talk | contribs) at 18:06, 2 February 2010 (Help page for how to use markup validation.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The W3C Markup Validation Service lets editors check web pages for conformance to HTML and XHTML standards. It is helpful for catching minor problems such as duplicate section names or citation IDs. Although most major browsers will tolerate many of the errors, and will display a document successfully even if it contains errors, they may misbehave on documents that contain the errors: for example, they may go to the wrong section or citation if you click the mouse on a wikilink. Checking that a page contains valid HTML can thus fix these minor glitches while also increasing portability to unusual browsers.

To check the HTML for a Wikipedia article XYZ, visit the service's home page and enter the text "//en.wikipedia.org/wiki/XYZ".

Common diagnostics and how to fix them

This section gives examples of diagnostics generated by the markup validation service, and suggests possible fixes. Diagnostics are by line and column of the generated HTML for the page. It may be helpful to obtain the HTML in order to understand the diagnostic. For example, if you using the Firefox browser, you can type control-U to see the HTML.

CITEREF already defined

Line 630, Column 88: ID "CITEREFBarker2008" already defined
…</a></b> <span class="citation" id="CITEREFBarker2008">Barker, Janice (2008-0
An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).

This diagnostic occurs if an article contains multiple invocations of the {{citation}} template with the same author and year. Disambiguate them by putting letters after the years (e.g., |year=2025a, |year=2025b), or by using the |ref= parameter of {{citation}}. If this problem occurs often, and if you don't need internal wikilinks to citations, consider switching to the {{cite book}} or {{vcite book}} template families, which do not have this problem.

Invalid character at start of identifier

Line 298, Column 220: value of attribute "id" invalid: "." cannot start a name
…span> <span class="mw-headline" id=".22We_Are_One.22_concert">"We Are One" co
It is possible that you violated the naming convention for this attribute. For example, id and name attributes must begin with a letter, not a digit.

This diagnostic occurs if an anchor starts with a character that is not a letter. A typical case is if a section header begins with a non-letter. The above diagnostic was prompted by the Wiki markup '=== "We Are One" concert ==='. This sort of problem can be fixed by rewording the header, for example, '=== Concert: "We Are One" ==='.

CSS validation

The W3C also has a CSS validator, but this is less of an issue when editing Wikipedia pages, as CSS is an option and CSS validation errors typically are due to problems with skins, not problems in individual pages.