Skip to content
Related Articles

Related Articles

Improve Article

How to set the language of text in the linked document in HTML5 ?

  • Last Updated : 06 Apr, 2021

The approach of this article is to specify the language of the text in the linked document in HTML5 by using a hreflang attribute in the HTML Tag.The value (or languageCode) passed here is code of the linked document. (for e.g. if the document/website in the given link is in English en is passed as  the value).

Syntax

<element hreflang="language_code"> 

Example 1: Below code illustrates the use of hreflang attribute in link element. 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <link id="linkid" rel="stylesheet"
          type="text/css" href="styles.css" 
          sizes="16*16" hreflang="en-us">
</head>
  
<body style="text-align:center;">
    <h1>GeeksForGeeks</h1>
  
    <h2>
        How to specify the language of the 
        text in the linked document in HTML5?
    </h2>
</body>
  
</html>

Output: Above link document written in English Language.



Example 2: 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <link id="linkid"
        rel="stylesheet"
        type="text/css"
        href="styles.css"
        sizes="16*16"
        hreflang="es">
</head>
  
<body style="text-align:center;">
    <h1>GeeksForGeeks</h1>
  
    <h2>
        How to specify the language of the
        text in the linked document in HTML5?
    </h2>
</body>
  
</html>

Output: Above link document written in Spanish Language. 

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :