lang

lang attribute specifies the primary language used in contents and attributes containing text content of particular elements.

There is also an xml:lang attribute (with namespace). If both of them are defined, the one with namespace is used and the one without is ignored.

In SVG 1.1 there was a lang attribute defined with a different meaning and only applying to <glyph> elements. That attribute specified a list of languages according to RFC 5646: Tags for Identifying Languages (also known as BCP 47) . The glyph was meant to be used if the xml:lang attribute exactly matched one of the languages given in the value of this parameter, or if the xml:lang attribute exactly equaled a prefix of one of the languages given in the value of this parameter such that the first tag character following the prefix was "-".

You can use this attribute with any SVG element.

范例

<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">
  <text lang="en-US">This is some English text</text>
</svg>

					

用法注意事项

<language-tag>
默认值 None
Animatable No
<language-tag>

This value specifies the language used for the element. The syntax of this value is defined in RFC 5646: Tags for Identifying Languages (also known as BCP 47) .

The most common syntax is a value formed by a lowercase two-character part for the language and an uppercase two-character part for the region or country, separated by a minus sign, e.g. en-US for US English or de-AT for Austrian German.

规范

规范 状态 注释
Scalable Vector Graphics (SVG) 2
The definition of 'lang' in that specification.
候选推荐 Made the lang attribute (without namespace) available on all elements and defined the interaction between both.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'lang' in that specification.
推荐 Deprecated definition of the attribute for <glyph> 元素

浏览器兼容性

BCD tables only load in the browser

另请参阅

Found a problem with this page?

最后修改: , 由 MDN 贡献者