在html根元素的lang属性中定义多种语言? [英] Define multiple languages in html root element's lang attribute?
问题描述
我想为文档确定一种以上的语言,因为它可以以多种语言提供.如果我使用:
I want to determine more than one language for a document, because it's available in more than one language. If I use:
<meta http-equiv="content-language" content="en,de,fr" />
这不是W3C有效的,验证器说我应该在根的lang
属性中定义它,但是此属性仅支持一种语言:
this is not W3C valid and the validator says I should define it in the root's lang
attribute, but this attribute only supports one language:
<html lang="en">
可以,但是不能
<html lang="de,en,fr">
那我应该在哪里定义它呢?
So where should I define it?
推荐答案
所有属性仅支持一种语言,因此,我认为您应该只定义一种语言.应该设置最重要的语言.如果您在一个文档中使用多种语言,则无法完成此操作,因此以下是解决问题的信息:
All attributes support only one language, so I believe you should define only one language; the most important language should be set. This can't be done if you have multiple languages on a single document, so here is the info to solve your problem:
lang和xml:lang属性不允许您将多个语言分配给单个文档.因此,如果您要用多种语言编写网页,则有两个选择:
The lang and xml:lang attributes do not allow you to assign multiple languages to a single document. So if you're writing a Web page with multiple languages you have two options:
- 使用
lang
属性定义主要语言,然后在文档中的元素上调用具有lang
属性的次要语言 -
根据需要在文档的特定部分中定义
lang
:
- Define a primary language with the
lang
attribute, and then call out the secondary language(s) withlang
attributes on elements in the document Define
lang
in the specific sections of the document as needed:
<div lang="fr-CA" xml:lang="fr-CA">
Canadian French content...
</div>
<div lang="en-CA" xml:lang="en-CA">
Canadian English content...
</div>
<div lang="nl-NL" xml:lang="nl-NL">
Netherlands, Dutch content...
</div>
我有一些多语言页面,并且确实使用了第二个选项.
I have some multiple-language pages and I do use the 2nd option.
您可能想阅读 http://www.w3.org/TR/2007/NOTE-i18n-html-tech-lang-20070412/#ri20060630.133619987
这篇关于在html根元素的lang属性中定义多种语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!