使用外部谷歌CSS验证CSS 2.1



我使用的是Google API的CSS文件:

<link href="http://fonts.googleapis.com/css?family=Ruthie" 
      rel="stylesheet" type="text/css" />

它看起来像这样:

@font-face {
  font-family: 'Ruthie';
  font-style: normal;
  font-weight: 400;
  src: local('Ruthie'), local('Ruthie-Regular'),
  url('http://themes.googleusercontent.com/static/fonts/ruthie/v3/Di1LdjRzoaEvDmrQy1l_ww.woff') format('woff');
}

但是W3C CSS验证器返回4个错误:

1) Value Error : font-family Property font-family doesn't exist 
   in CSS level 2.1 but exists in [css1, css2, css3] : 'Ruthie'
2) ...

您可以通过验证页面来检查所有错误http://fonts.googleapis.com/css?family=Ruthie

所以我的问题是:

1) 如何使用不同的CSS版本(如2)进行验证?这是一个好方法吗?

2) 如何修复这些错误,最终使用类似的字体并删除此API?

3) 此外,我想确切地理解为什么这个CSS是无效的。。。

您可以验证CSS级别3,Google提供的代码是有效的CSS3。这不是有效的CSS2.1代码,因为在CSS2.1规范中没有@font face。@font-face在CSS字体模块级别3:4.1@font face规则中定义。

@font-face规则已经在CSS2中定义,但显然没有包含在CSS2.1中。因此,无法在CSS2.1中验证样式表,只能在CSS3或CSS2中验证。

最新更新