1 point

Anchor Tag <a> for opening hyperlinks


dashboard

Wed Jan 08 2020 19:00:00 GMT+0000 (UTC)

Posted by @intern00001 #html #webdev #basics #html5

<a
	href="www.example.com"
    alt="text that describes image"
    target="_blank"
    download="/images/photo.jpg"
    hreflang="en"
    media="projection and (resolution:300dpi)"
    referrerpolicy="no-referrer"
    rel="external"
    type="text/html"
	ping="www.example.com/trackclicks"
/>
	Click here to visit our site!
</a>
content_copy

line 2: href defines the target URL. If it is an internal link, there is no need to write the domain. e.g. href="/about". This option is compulsory. line 3: alt describes the image in words. Used for accessibility purposes and in cases where the image fails to load. This is not compulsory but highly recommended. In many countries it is illegal not to add alt tags. Also good for SEO. line 4: Defines where to open the link. By default, it will open in the same browser. If you wish to open in a new tab, then use target="_blank". For the same window, use "_self". This is optional. line 5: use this option when you want users to download a file when they click. This is optional. line 6: specifies the language of the document in the link. Not necessary unless you have a multi-lingual site. line 7: specifies which kind of media and device the link is optimized for. In this example, it is for a projector at resolution 300dpi. Other options are print, braille, handheld, etc. This is not necessary. line 8: defines which referrer is sent when fetching the resource. Can be origin of the page or no referrer at all. Optional and unnecessary. line 9: specifies the relationship between the current document and the linked document. Examples are author, bookmark, external, help. This is optional. line 10: specifies the media type of the linked document line 11: This option is useful for monitoring/tracking. Can include a list of URL's which get a notification when a user clicks the hyperlink. line 13: this line of text is what users will see and click on. This is compulsory, otherwise users won't know where to click. You can direct their attention with CSS styling or by telling them to "click here"


>> Browse more code snippets

more_vert