- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我想问你如何在 HTML 代码中正确使用 lang。我正在尝试使用 2 种语言 en, pl 制作网站。
<html lang="en">
<html lang="pl">
这种方式是否正确?
最佳答案
如果文档的主要语言是波兰语,大部分是英语,那么它应该有 <html lang="pl">
与 <div lang="en">
或英文部分周围的东西:
<html lang="pl">
…
<body>
[Polish content]
<div lang="en">
[English content]
</div>
[more Polish content]
<div lang="en">
[more English content]
</div>
[more Polish content]
…
无论 html
如果可能的话,元素应该总是有一个 lang
值,per the HTML spec :
Authors are encouraged to specify a
lang
attribute on the roothtml
element, giving the document's language. This aids speech synthesis tools to determine what pronunciations to use, translation tools to determine what rules to use, and so forth.
但是,如果一个文档是多种语言的混合体,那么它就不能真正被视为具有单一的主要语言,then the html
element still should have a lang
attribute, but with an empty value :
Setting the attribute to the empty string indicates that the primary language is unknown.
<html lang="">
…
<body>
<div lang="pl">
[Polish content]
</div>
<div lang="en">
[English content]
</div>
<div lang="pl">
[Polish content]
</div>
<div lang="en">
[English content]
</div>
…
有关这方面的更多详细信息,请参阅以下 W3C 指南:
关于html - 如何在 HTML 中正确使用 lang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40828205/
我是一名优秀的程序员,十分优秀!