- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
`?-6ren"> `?-在 HTML5 中使用 SVG 时:是 XML 声明 SVG 需要 作为图像通过 或 作为 CSS background-image是吗? 这与“Are SVG parameters such as-6ren">
在 HTML5 中使用 SVG 时:是 XML 声明 <?xml version="1.0" encoding="UTF-8"?>
SVG 需要
<img>
或background-image
是吗?这与“Are SVG parameters such as 'xmlns' and 'version' needed ”。两个答案和 MDN Namespace crash course 对命名空间问题进行了必要的澄清。 .
但是 SVG 1.1 没有包含关于 XML 声明的必要性或何时可以省略的声明?
没有声明的例子:
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
<circle id="circle--red" cx="30" cy="30" r="30" fill="#f00"/>
</svg>
2016 年 7 月 4 日更新:澄清问题是关于 XML 声明。谢谢@Martin Honnen!2017 年 10 月 24 日更新:更改为 “UTF-8“ uppercase和 SVGO 优化的属性顺序。
最佳答案
对于 HTML5,正确的 DOCTYPE declaration是
<!DOCTYPE html>
需要给浏览器指定全标准模式。
你展示了什么,
<?xml version="1.0" encoding="utf-8"?>
是一个XML declaration .是optional for XML 1.0和 required for XML 1.1 , 但是
version="1.0"
和 encoding="utf-8"
无论如何都是默认值。当您希望指定不同的编码时,请在 HTML5 中使用 XML 声明,尤其是当文件可能不仅被浏览器而且还被 XML 处理器使用时。
有关详细信息,请参阅 HTML5: A vocabulary and associated APIs for HTML and XHTML 。
关于内部 SVG 的注意事项(感谢 @Quentin):HTML5 文档中嵌入的 SVG 不应有独立的 XML 声明。在格式良好的 XML 中只允许一个 XML 声明,并且它必须在顶部, 如果有的话。参见 this answer有关 XML 声明放置要求的更多详细信息。
关于外部 SVG 的注意事项(感谢 @Kaiido):通过 HTML5 img
或 CSS background-images
引用的 SVG 必须有自己的XML 声明并应使用以下 DOCTYPE 声明:
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
关于外部 SVG(更新)的注意事项(感谢,@user314159):
根据 1.3. SVG namespace and DTD的 Scalable Vector Graphics (SVG) 2 W3C Working Draft 09 July 2015 :
A DTD is not provided in this specification, as the use of DTDs for validating documents is known to be problematic. In particular, DTDs do not handle namespaces gracefully and the range of constraints they can express is limited. It is recommended that authors do not include a DOCTYPE declaration in SVG documents.
[强调已添加。]
关于xml - HTML5 中的 SVG – 什么时候需要 XML 声明 `<?xml version="1. 0"encoding="UTF- 8"?>`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38169475/
我使用术语“词法编码”是因为我没有更好的编码。 与字母相反,单词可以说是交流的基本单位。 Unicode 尝试为所有已知字母表的每个字母分配一个数值。对一种语言来说是字母,对另一种语言来说是字形。 U
我在UTF-8中有csv文件,我想将其保存在西里尔字母(Windows 1251)中...在中,我仅找到Atom -重新打开,并使用ctrl+shift+u编码 在 Sublime Text 3 中,
在lua 5.3引用手册中,我们可以看到: Lua is also encoding-agnostic; it makes no assumptions about the contents of a
看完后how gzip compression works它让我思考。如果源和代理服务器 (CDN) 都支持 gzip,则添加 Vary: Accept-Encoding头需要吗? 最佳答案 Vary
我正在向我的项目添加一项功能,我们将生成指向我们网站内部内容的链接,并且我们希望这些链接尽可能短,因此我们将制作自己的“URL 缩短器”。 我想知道生成的短网址的最佳编码/字母表是什么。这很大程度上是
我构建了一个用于压缩 HTTP 输出的模块。阅读spec ,我在以下几件事上没有发现明显的区别: 接受编码: 是否应将其视为与 Accept-Encoding: * 相同,还是视为不存在 header
在下面的代码中: package main import ( "bytes" "encoding/json" "fmt" ) type Student struct {
这个问题在这里已经有了答案: Why does encode delete the argument? (1 个回答) 6年前关闭。 Encode::encode 的文档说: encode $octe
在Android4.1中,实时编码应用中经常会请求关键帧。但是如何使用 MediaCodec 对象呢?当前的 Android4.2 SDK 似乎不支持它。 最佳答案 您可以 通过在排队输入缓冲区时指定
我有 CSV 格式的数据,这些数据在字符编码方面被严重打乱,可能在不同的软件应用程序(LibreOffice Calc、Microsoft、Excel、Google Refine、自定义 PHP/My
您可能知道,在 Perl 中,“utf8”意味着 Perl 对 UTF-8 的宽松理解,它允许使用技术上不是 UTF-8 中有效代码点的字符。相比之下,“UTF-8”(或“utf-8”)是 Perl
本文整理了Java中org.geotools.ysld.encode.YsldEncoder.encode()方法的一些代码示例,展示了YsldEncoder.encode()的具体用法。这些代码示例
现在还没有任何关于红色的书,因为它太新了。因此,我正在尝试遵循一本旧的 Rebol 书,并从中挽救我能得到的东西。 我发现一些命令,例如 read,由于文件编码的原因,我无法执行代码。 save %
错误:无法映射用于编码 UTF-8 的字符。由于版权特征,我收到此错误。我使用的是 Netbeans 7.2。 /** * � 2006 * * This class was generate
现在还没有任何关于红色的书,因为它太新了。因此,我正在尝试遵循一本旧的 Rebol 书,并从中挽救我能得到的东西。 我发现一些命令,例如 read,由于文件编码的原因,我无法执行代码。 save %
错误:无法映射用于编码 UTF-8 的字符。由于版权特征,我收到此错误。我使用的是 Netbeans 7.2。 /** * � 2006 * * This class was generate
我正在尝试使用客户端提供的值在 PHP 中测试 Soap Security header 。 他们提供的值(value)如... wTAmCL9tmg6KNpeAQOYubw== ...并说这是一个
这个问题已经有答案了: ClassNotFoundException/NoClassDefFoundError in my Java web application (3 个回答) 已关闭 8 年前。
世界!我正在使用 .Net Framework 4 System.Net.Sockets.TcpClient 编写简单的 HTML 服务器。 我在 StringBuilder html 中有 HTML
我正在尝试使用 Yii 来提供网络服务。自动生成的 wsdl 如下。我可以从命令行成功使用 Web 服务,但是通过 Web 浏览器,我得到了 SOAP-ERROR: Encoding: Violati
我是一名优秀的程序员,十分优秀!