HTML <a> element

HTML links are hyperlinks.
Links are found in nearly all web pages. Links allow users to click their way from page to page.

<a> element

The HTML <a> element with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.

        <a href="https://www.google.com" >
            Go to google homepage
        </a>

The most important attribute of the <a> element is the href attribute, which indicates the link's destination


Go to google homepage



HTML link target attributes

By default, the linked page will be displayed in the current browser window. To change this, you must specify another target for the link.
The target attribute specifies where to open the linked document. Values are:

  • _self which is default, opens in same window/tab as it was clicked
  • _blank opens in new window/tab
  • _parent opens in the parent frame
  • _top opens in the topmost browsing
  •         <a href="https://www.google.com" target="_self" >
                self target link
            </a>
            <a href="https://www.google.com" target="_blank" >
                blank target link
            </a>

    self target link
    blank target link



    Image as link

    To use an image as a link, just put the <img> tag inside the <a> tag:

            <a href="https://www.google.com" >
                <img src="link_img.gif" alt="link_img" width="150" >
            </a>

    link_img