Hyperlinks

<a> - link tag

Href

href - contains reference, i.e. URL. this is required attribute

Values

#footer - hash link to element with some id. it is used to send user to specific part of the page

  • # - dead link, which refers nowhere


javascript:foo() - script URL. it is used to make browser treat href value not as reference but as JS code

  • e.g. href="javascript:void(0)" - do nothing
  • there is a security risk, because script URL is a form of eval

there are special href values, which can trigger external application

mailto:email-address - send email

  • subject - letter topic
  • body - letter text
  • cc - copy
  • bcc - hidden copy
  • e.g. href="example@email.com?subject={subject}&body={body}&cc={copy@email.com}"


sms:phone-number - send SMS

  • body might be used
  • e.g. href="sms:+380123456789?body=Hello my friend"


tel:phone-number - make a call

Other Attributes

target - set where to open a link

  • _self - default
  • _blank - open in a new tab. this option automatically enables rel="noopener" behaviour
  • _parent - the parent browsing context


download - the target will be downloaded when a user clicks on the hyperlink

  • <value> - is the new name of the file. extension is automatically detected and added
  • if the value is omitted, the original filename is used


rel

  • noreferrer
  • noopener
  • nofollow
  • noindex
;