HTML5: Specify the language of the document in a given link?

Go To Hyperlink page

Solution :

HTML Code :

<!-- Declare the document type as HTML5 -->
<!DOCTYPE html>

<!-- Start the HTML document -->

<!-- Start the head section containing metadata about the document -->

<!-- Set the character encoding to UTF-8 -->
<meta charset="utf-8">

<!-- Set the title of the document to "How to create a hyperlink" -->
<title>How to create a hyperlink</title>

<!-- Close the head section -->

<!-- Start the body section containing the content of the document -->

<!-- Create a hyperlink with a specified URL and language -->
<a href="https://w3resource.com" hreflang="en">w3resource Tutorial</a>

<!-- Close the body section -->

<!-- Close the HTML document -->


The above HTML code defines a basic HTML5 document with metadata in the head section and a body containing a hyperlink. The hyperlink has a specified URL, and the 'hreflang' attribute indicates the language of the linked resource.

  • <!DOCTYPE html>: Declares the document type as HTML5.
  • <html>: Marks the beginning of the HTML document.
  • <head>: Contains metadata about the document, such as character encoding and the title.
  • <meta charset="utf-8">: Sets the character encoding to UTF-8.
  • <title>How to create a hyperlink</title>: Sets the title of the HTML document.
  • </head>: Closes the head section.
  • <body>: Contains the actual HTML document content.
  • <a href="https://w3resource.com" hreflang="en">w3resource Tutorial</a>: Creates a hyperlink to "https://w3resource.com" with the specified language attribute set to "en" for English.
  • </body>: Closes the body section.
  • </html>: Marks the end of the HTML document.

Live Demo :

See the Pen a_hreflang-answer by w3resource (@w3resource) on CodePen.

View the example in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo

Go To Hyperlink page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Follow us on Facebook and Twitter for latest update.