Css 简明教程

CSS - Validations

验证是在根据规则检查某些东西的过程。当您还是初学者时,在编写 CSS 规则时会犯很多错误是很常见的。您将如何确保您所写的内容 100% 准确且符合 W3 质量标准?

Validation is the process of checking something against a rule. When you are a beginner, it is very common that you will commit many mistakes in writing your CSS rules. How you will make sure whatever you have written is 100% accurate and up to the W3 quality standards?

如果您使用 CSS,您的代码必须正确。不正确的代码可能会导致您的页面外观或功能出现意外结果。

If you use CSS, your code needs to be correct. Improper code may cause unexpected results in how your page looks or functions.

但是,如果您要验证嵌入在 (X)HTML 文档中的 CSS 样式表,您应该首先检查您使用的 (X)HTML 是否有效。

But if you want to validate your CSS style sheet embedded in an (X)HTML document, you should first check that the (X)HTML you use is valid.

检查 (X)HTML 文档有效性的工具: Validate (X)HTML document

Tool to check the validity of (X)HTML document: Validate (X)HTML document.

您可以使用以下工具来检查 CSS 的有效性。

You can use the following tools to check the validity of your CSS.

CSS 验证器检查您的级联样式表,以确保它们符合 W3 联盟设定的 CSS 标准。有少数验证器还将告诉您哪些 CSS 特性受哪些浏览器支持(因为并非所有浏览器在 CSS 实现都相同)。

A CSS validator checks your Cascading Style Sheets to make sure that they comply with the CSS standards set by the W3 Consortium. There are a few validators which will also tell you which CSS features are supported by which browsers (since not all browsers are equal in their CSS implementation).

Why Validate Your HTML Code?

有许多原因需要验证你的代码。但主要原因有 −

There are a number of reasons why you should validate your code. But major ones are −

  1. It Helps Cross-Browser, Cross-Platform, and Future Compatibility.

  2. A good quality website increases search engine visibility.

  3. Professionalism: As a web developer, your code should not raise errors while seen by the visitors.