How add and use hyperlinks

Element <a> allow user:

  • open another document (hyperlink)
  • jump to another part of current document (anchor)
  • open or download some web-resource like image or archive file
  • make some action, that related with scheme of url, as example, send email

Main attrubutes of a are href, target, rel, download.

example code result
<!-- hyperlink -->
<a href="https://google.com" target="_blank">google</a>
<br>
     
<!-- anchor, jump to bookmark -->
<a href="#bottom">scroll to bottom</a>
<br>

<!-- send email -->
<a href = "mailto:abc@example.com">send email</a>
<br>

<!--  launch the phone app and
initiate dialing of the specified phone number -->
<a href="tel:1-408-555-5555">1-408-555-5555</a>
google
scroll to bottom
send email
1-408-555-5555

Attribute href

href defines the link address. It can be absolute address or relative.

Every element can have attribute id, its value used as bookmark. Bookmark is pointed in href after # sign.

Attribute target

targetspecifies where to open the linked document, can have one of the following values:

  • _blank opens the linked document in a new window or tab
  • _self opens the linked document in the same window/tab as it was clicked, this is default value
  • _parent opens the linked document in the parent frame
  • _top opens the linked document in the full body of the window
  • frame_name opens the linked document in a named frame

Attribute rel

rel describes the relationship between the current document and the destination URI. Can be used when the href attribute is present. Multiple values can be provided, separated by a space. Some possible values:

  • alternate gives alternate representations of the current document
  • author gives a link to the current document's author
  • license indicates that the main content of the current document is covered by the copyright license described by the referenced document
  • prev indicates that the current document is a part of a series, and that the previous document in the series is the referenced document
  • next indicates that the current document is a part of a series, and that the next document in the series is the referenced document
  • nofollow indicates that the current document's original author or publisher does not endorse the referenced document. this value is often used to declare paid links to search engines such as Google.

Attribute download

download specifies that the target will be downloaded when a user clicks on the hyperlink.
If the value is omitted, the original filename is used.

<a href="/images/myimage.jpg" download> download myimage </a>
<a href="/images/myimage.jpg" download="saved_myimage.jpg" > download myimage </a>

this place is bookmarked