什么< html lang ="">属性值应该用于混合语言页面吗? [英] What <html lang=""> attribute value should I use for a mixed language page?

查看:151
本文介绍了什么< html lang ="">属性值应该用于混合语言页面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常用这个:< html lang =en>



然而,我我在一个网站上工作,该网站将使用两种语言,并且有时将它们混合在相同的句子或标题中。



上面的代码在这种情况下会怎样?我可以使用< html lang =lang1 lang2>

解决方案

据我所知,通过阅读HTML5规范可以发现 lang 属性:


值必须是有效的BCP 47语言标记或空字符串

来源:http://www.w3.org/TR/html5/dom.html#the-lang- and-xml:lang-attributes



在规范中没有提及语言字符串数组,我发现每个示例都使用单一语言字符串。

这是有道理的,因为除非我们创建一个新的混合语言,否则真正的给定部分只能使用一种语言。



由于lang属性在所有HTML元素上都有效,因此您可以将语言特定代码包装在新标签中以指示其语言。

 < html lang =en> 
[...]
< body>
< h1>我是标题< span lang =de-DE> EineÜberschrift< / span>< / h1>
< / body>
< / html>


I usually use this: <html lang="en">.

However, I am working on a website that will use two languages and mix them up sometimes in the same sentence or heading.

How would the above code look in this case? Can I use <html lang="lang1 lang2">?

解决方案

As far as I can tell from reading the HTML5 spec the lang attribute:

value must be a valid BCP 47 language tag, or the empty string

Source: http://www.w3.org/TR/html5/dom.html#the-lang-and-xml:lang-attributes

There's no mention in the spec of an array of language strings and every example I've found uses a single language string.

This makes sense since really a given section can only be in one language unless we're creating a new hybrid language.

Since the lang attribute is valid on all HTML elements you can wrap your language specific code in a new tag in order to indicate its language.

<html lang="en">
[...]
<body>
<h1>I am a heading <span lang="de-DE">Eine Überschrift</span></h1>
</body>
</html>

这篇关于什么&lt; html lang =&quot;&quot;&gt;属性值应该用于混合语言页面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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