Google字体网址在w3.org上打破HTML5验证

问题描述 投票:172回答:5

我使用此HTML标记加载了3种不同大小的字体:

<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,800,700,400italic|PT+Serif:400,400italic|Bree+Serif">

直到大约1/2周之前,w3.org validator支持HTML5;现在它给出了这个错误:

 Line 14, Column 163: Bad value http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,800,700,400italic|PT+Serif:400,400italic|Bree+Serif for attribute href on element link: Illegal character in query: not a URL code point.

W3C Markup Validator现在不喜欢什么?

html5 w3c-validation google-font-api
5个回答
316
投票

URL编码|属性(href)中的%7C(管道符):

<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,800,700,400italic%7CPT+Serif:400,400italic%7CBree+Serif">

7
投票

http://www.utf8-chartable.de/

您必须替换字符|通过其相应的UTF-8字符给出

href="http://fonts.googleapis.com/css?family=Cookie%7cAmaranth%7cKaushan+Script%7cCousine%7cBilbo+Swash+Caps%7cRancho&amp;effect=shadow-multiple"

6
投票

有两种方法可以解决此验证问题:

  1. URL编码|元素的href属性中的link(垂直条/线)字符(如%7C): <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,800,700,400italic%7CPT+Serif:400,400italic%7CBree+Serif">
  2. 使用多个link元素分隔字体包含: <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,800,700,400italic"> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=PT+Serif:400,400italic"> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Bree+Serif">

-3
投票

我的情况是疯狂的换行符。请参阅附图.enter image description here


-4
投票

我是scape&with“&amp;”并且工作正常,例如:

<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700&amp;subset=latin,latin-ext' rel='stylesheet' type='text/css' />
© www.soinside.com 2019 - 2024. All rights reserved.