XML technologies / CSS / Advanced websites with CSS / Validation and backward compatibility / CSS page validation

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

Test stylesheets in browsers and validate them too. It is easy and free: submit pages to W3C, and error-free ones may display the icon below.

  W3C icon for CSS compliance

Figure: Official W3C icon for CSS compliance.

Visit W3C: CSS Validation Service and follow instructions. Automatic redirection to German is normal; the site detects language. The figure shows its German start page.

The W3C CSS validator

Figure: The W3C CSS validator.

Three methods are offered: URL, uploaded CSS file or CSS pasted into a text field.

A CSS or HTML URL is easiest. For HTML, all linked sheets and embedded CSS are checked. Upload local files and linked resources to a server for access.

Our URI example leads to the page below. These forms use default options, adjustable at any time.

A W3C CSS validator variant

Figure: A W3C CSS validator variant.

There are three drop-down menus:

“Warnings” has four severity-reporting settings:

Warnings are not CSS errors. Errors prevent proper operation, but valid code may still use deprecated or misapplied markup. Equal text and background colors trigger a warning: valid CSS, potentially problematic rendering.

Keep the default “Normal report” unless experience and a specific reason justify changing it.

“Profile” selects the CSS standard to validate against, with eleven options:

Only the first four matter here, selecting CSS versions. SVG, mobile and TV profiles belong elsewhere and can be ignored.

The default is CSS 2; I recommend CSS 2.1 as the latest broadly supported version.

“Medium” selects the stylesheet’s output medium.

Click “Submit URI” to send the CSS or HTML file. The validator loads and checks it, then reports validity with an icon link (see Official W3C icon for CSS compliance) or lists syntax violations.

CSS validation requires valid HTML, especially the “document parse tree.” Otherwise it cannot work correctly.

The CSS site links to W3C’s HTML validator through “valid HTML.” Validate HTML first, including its prolog, DOCTYPE and correct display parameters. Without these, validation cannot begin and immediately reports an error.

  

 

 

 

back to top