SVG xml:lang Attribute

The xml:lang attribute in SVG is used to indicate the primary language that is used in the contents and attributes containing text content on the website. It is allowed in all XML dialects as it is a universal attribute. All elements use this attribute.

Syntax:

xml:lang = "language-tag"

Attribute Values: The attribute accepts values as mentioned above and described below:

  • language-tag: This value indicates the language used for the given element. The language is defined according to the BCP 47 specification.

Example 1:

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1 style="color: green; 
            margin-left: 80px;">
        w3wiki
    </h1>
  
    <svg viewBox="-5 -20 800 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <text xml:lang="en-US">
            It is a Computer
            Science portal.
        </text>
    </svg>
</body>
  
</html>


Output:

Example 2:

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1 style="color: green; 
            margin-left: 100px;
            font-size: 30px;">
        w3wiki
    </h1>
      
    <svg viewBox="20 -10 200 100" 
        xmlns="http://www.w3.org/2000/svg">
        <text xml:lang="ar">
            مرحبا
        </text>
    </svg>
</body>
  
</html>


Output: