简体   繁体   English

具有:required,:valid和:invalid的css3验证错误

[英]css3 validation errors with :required, :valid, and :invalid

I keep getting CSS3 validation errors from W3C for my CSS code and am not sure why. 我不断从W3C收到我的CSS代码的CSS3验证错误,但不确定为什么。 Any ideas would be greatly appreciated. 任何想法将不胜感激。 Here is my code. 这是我的代码。

input:required, input[required] {
    border: 2px solid red;
    color: #800000;
}
input:valid {
    border: 1px solid black;
    color: #800000;
}
input:invalid {
    box-shadow: none;
    border: 2px solid red;

}

Your CSS is valid. 您的CSS有效。 The validator just doesn't recognize the :required , :valid and :invalid pseudo-classes. 验证器只是无法识别:required:valid:invalid伪类。 Don't worry about it. 不用担心

Pseudo-classes such as :required are not part of CSS, even CSS3, according to definitions applied by the W3C CSS Validator. 根据W3C CSS验证程序应用的定义,诸如:required类的伪类不是CSS的一部分,甚至不是CSS3的一部分。 Generally, what the validator sees as CSS3 is CSS specifications published as W3C Recommendation, Proposed Recommendation, or Candidate Recommendation. 通常,验证者将CSS3视为发布为W3C建议书,提议的建议书或候选建议书的CSS规范。 Less mature specifications (mostly Working Drafts) are usually not included. 通常不包括较不成熟的规范(主要是工作草案)。 There is no official statement on this; 对此没有官方声明; it just seems to be the adopted approach. 这似乎只是采用的方法。

Thus, for the time being, you need to check manually whether your use of such constructs matches the documents that you wish to adhere to. 因此,目前,您需要手动检查您对此类构造的使用是否与您希望遵守的文档相匹配。

Note that Working Draft documents may change at any moment without notice and carry a boilerplate text that they should not be cited except as work in progress. 请注意,工作草案文档可能随时更改,恕不另行通知,并带有样板文字,除非正在进行中,否则请勿引用。 Moreover, implementation status varies a lot. 而且,实施状态变化很大。

However, these pseudo-classes are special in the sense that on the CSS track, they are still at a Working Draft level, but they are widely implemented in modern browsers and they have a de facto standard definition in HTML5 . 但是,这些伪类在CSS轨道上仍处于工作草案级别,这是特殊的,但是它们在现代浏览器中得到了广泛实现,并且它们在HTML5中具有事实上的标准定义。 (It's odd that an HTML specification defines CSS constructs, but apparently its authors were frustrated at the slow progress on the CSS track.) (奇怪的是,HTML规范定义了CSS构造,但显然,其作者对CSS跟踪进展缓慢感到沮丧。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM