w3resource

HTML5: How to create a hyperlink?

Go to Hyperlink page

Solution :

HTML Code:

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

<!-- Start the HTML document -->
<html>

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

<!-- 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 -->
</head>

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

<!-- Create a paragraph containing a hyperlink -->
<p><a href="https://www.w3resource.com/">w3resource.com</a></p>

<!-- Close the body section -->
</body>

<!-- Close the HTML document -->
</html>

Explanation:

The above HTML code defines a basic HTML5 document with metadata in the head section and a body containing a paragraph with a hyperlink pointing to "https://www.w3resource.com/". The document title is set to "How to create a hyperlink." This is a simple example demonstrating the structure of an HTML document with a hyperlink.

  • <!DOCTYPE html>:
    • This declaration specifies that the document type is HTML5, indicating the HTML version being used.
  • <html>:
    • This tag marks the beginning of an HTML document.
  • <head>:
    • The 'head' section contains metadata about the HTML document, such as character encoding and title.
  • <meta charset="utf-8">:
    • This meta tag sets the character encoding to UTF-8, a widely used character encoding standard.
  • <title>How to create a hyperlink</title>:
    • The title tag sets the HTML document title, which is often displayed in the browser's title bar or tab.
  • </head>:
    • Closes the HTML document's head section.
  • <body>:
    • The body section contains the actual HTML document content.
  • <p><a href="https://www.w3resource.com/">w3resource.com</a></p>:
    • Create a paragraph (<p>) containing a hyperlink (<a>) with the text "w3resource.com" and a link (href) to "https://www.w3resource.com/".
  • </body>:
    • Closes the HTML document's body section.
  • </html>:
    • Mark the end of the HTML document.

Live Demo :

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

See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

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.