Page 22 - HTML5
P. 22

Chapter 2: Anchors and Hyperlinks




        Introduction



        Anchor tags are commonly used to link separate webpages, but they can also be used to link
        between different places in a single document, often within table of contents or even launch
        external applications. This topic explains the implementation and application of HTML anchor tags
        in various roles.


        Syntax


            •  <a href="URL or anchor">Link Text</a>


        Parameters




          Parameter     Details


                        Specifies the destination address. It can be an absolute or relative URL, or the
                        name of an anchor. An absolute URL is the complete URL of a website like
                        http://example.com/. A relative URL points to another directory and/or document
          href          inside the same website, e.g. /about-us/ points to the directory “about-us” inside
                        the root directory (/). When pointing to another directory without explicitly
                        specifying the document, web servers typically return the document “index.html”
                        inside that directory.

                        Specifies the language of the resource linked by the href attribute (which must
          hreflang      be present with this one). Use language values from BCP 47 for HTML5 and
                        RFC 1766 for HTML 4.


                        Specifies the relationship between the current document and the linked
          rel           document. For HTML5, the values must be defined in the specification or
                        registered in the Microformats wiki.

                        Specifies where to open the link, e.g. in a new tab or window. Possible values
                        are _blank, _self, _parent, _top, and framename (deprecated). Forcing such
          target
                        behaviour is not recommended since it violates the control of the user over a
                        website.


                        Specifies extra information about a link. The information is most often shown as
          title         a tooltip text when the cursor moves over the link. This attribute is not restricted
                        to links, it can be used on almost all HTML tags.

                        Specifies that the target will be downloaded when a user clicks on the hyperlink.
          download      The value of the attribute will be the name of the downloaded file. There are no
                        restrictions on allowed values, and the browser will automatically detect the



        https://riptutorial.com/                                                                                6
   17   18   19   20   21   22   23   24   25   26   27