w3resource

HTML5: How to create a nofollow link?

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 nofollow link" -->
<title>How to create a nofollow link</title>

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

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

<!-- Create a hyperlink with a specified URL and a rel="nofollow" attribute -->
<a rel="nofollow" href="http://example.com">Example.com</a>

<!-- 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 hyperlink. The hyperlink includes a 'rel' attribute set to "nofollow," indicating to search engines that they should not follow the link to influence the ranking of the linked site.

Here's a brief explanation of each part of HTML code:

  • <!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 nofollow link</title>: Sets the HTML document title.
  • </head>: Closes the head section.
  • <body>: Contains the actual HTML document content.
  • <a rel="nofollow" href="http://example.com">Example.com</a>: Creates a hyperlink with a specified URL ("http://example.com") and includes the 'rel' attribute set to "nofollow." This attribute tells search engines not to follow the link, affecting the target site's ranking.
  • </body>: Closes the body section.
  • </html>: Marks the end of the HTML document.

Live Demo :

See the Pen a_rel-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
YesYesYesYesYes

Go To Hyperlink page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/html-css-exercise/basic/a_rel-answer.php