使用Google字体:但是,根据W3C,代码是不是有效的HTML5? [英] Using Google fonts: however, the code is not valid HTML5 according to W3C?

查看:179
本文介绍了使用Google字体:但是,根据W3C,代码是不是有效的HTML5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理作业,而我正在为我的网站使用Google字体。我试图验证我的HTML使用W3C,因为我的任务必须是有效的,以获得满分,我不断得到谷歌字体代码的错误。我似乎无法弄清楚为什么。以下是代码:

 < link rel =stylesheettype =text / csshref =http:// fonts.googleapis.com/css?family=Orbitron|Special+Elite|Open+Sans\"> 

这里是我从W3C得到的错误信息:


错误的值 http: //fonts.googleapis.com/css?family=Orbitron|Special+Elite|Open+Sans 在元素链接上的属性href:查询中的非法字符:不是网址代码点。



... href =http://fonts.googleapis.com/css?family=Orbitron|Special+Elite|Open+Sans>



IRI参考语法:
任何URL。例如:/ hello,#canvas或 http://example.org/ 。字符应在NFC中表示,空格应该以%20的形式逃脱。


有什么想法?我对HTML5很新,所以我不确定我在这里错过了什么。

解决方案

这里的违规字符是|U + 007C垂直线,Google用它作为字体名称之间的分隔符;这是他们的一个糟糕的选择,因为|是一个保留的字符,都由URL生活标准(这是HTML5 CR引用的)和互联网标准STD 66( RFC 3986 )。

实际上,当您使用|时,它可以正常工作,但符合标准和草案,使用百分号编码在URL规范中),编写%7c (不区分大小写):

 < link rel =stylesheettype =text / csshref = 
http://fonts.googleapis.com/css?family=Orbitron%7cSpecial+Elite%7cOpen+Sans >


I'm working on an assignment, and I am using Google Fonts for my site. I'm trying to validate my HTML using W3C, as my assignments must be valid to get full marks, and I keep on getting an error for the Google Font code. I can't seem to figure out why. Here's the code:

<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Orbitron|Special+Elite|Open+Sans">

Here's the error message I am getting from W3C:

Bad value http://fonts.googleapis.com/css?family=Orbitron|Special+Elite|Open+Sans for attribute href on element link: Illegal character in query: not a URL code point.

…href="http://fonts.googleapis.com/css?family=Orbitron|Special+Elite|Open+Sans">

Syntax of IRI reference: Any URL. For example: /hello, #canvas, or http://example.org/. Characters should be represented in NFC and spaces should be escaped as %20.

Any thoughts? I'm pretty new to HTML5, so I'm unsure what I'm missing here.

解决方案

The offending character here is "|" U+007C VERTICAL LINE, used by Google as a separator between font names; that’s a poor choice by them, since "|" is a reserved character, both by the "URL Living Standard" (which is what the HTML5 CR cites) and by the Internet-standard STD 66 (RFC 3986).

In practice, it works fine when you use "|" as such, but to conform to the standards and drafts, use percent encoding (% encoding, as defined in the URL specifications) for it, writing %7c (case insensitive) instead:

<link rel="stylesheet" type="text/css" href=
"http://fonts.googleapis.com/css?family=Orbitron%7cSpecial+Elite%7cOpen+Sans">

这篇关于使用Google字体:但是,根据W3C,代码是不是有效的HTML5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆