a href Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:a

Description

The href attribute sets the URL of the page the link goes to.

Attribute Values

Value Description
URL The URL of the link.

Possible values:

  • An absolute URL - example, href="http://www.example.com/default.htm"
  • A relative URL - points to a file within a web site, like href="default.htm"
  • Link to an element with a specified id within the page (like href="#top")
  • Other protocols (like https://, ftp://, mailto:, file:, etc..)
  • A script (like href="javascript:console.log('Hello');")

The href attribute specifies the link's destination:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p><a hreflang="en" href="http://java2s.com">site</a></p>

</body><!--from   ww  w . ja  v  a2  s. c  o  m-->
</html>

Related Tutorials