<a> Tag
<a> tag is defined as an anchor tag. It starts with <a> tag and ends with </a> tag and anything written within these starting and ending tag becomes the link. This tag is used to create the link to another document, to give the links of any other sites or to create any type of link within your website and this tag is also used to create the bookmark inside a document. Use the href attribute to create the link. Herf attribute is the most important attribute of this tag. It is used to indicate the link's destination. You can use text, image, phrases, etc. as a link and use the name attribute to create the bookmark. <a> tag is mostly supported by all the commonly used browsers like- Internet Explorer, Mozilla Firefox, Opera, Google Chrome, Safari, etc. The default appearence of links in every browsers are-
- Link is underlined and blue in color if the link is unvisited.
- Link is underlined and purple in color if the link is visited.
- Link is underlined and red in color if the link is active.
The <a> tag is supported by some event and standard attributes. These attributes are-
Event attributes supported by the <a> tag-
Attribute | Description |
---|---|
onblur | In this case the script runs when an element loses focus |
onclick | In this case the script runs on a click of mouse |
ondblclick | In this case the script runs on a double click of mouse |
onfocus | In this case the script runs when an element gets focus |
onmousedown | In this case the script runs when the mouse button is pressed |
onmousemove | In this case the script runs when the mouse pointer moves over an element |
onmouseout | In this case the script runs when the mouse pointer moves out of an element |
onmouseover | In this case the script runs when the mouse pointer moves over an element |
onmouseup | In this case the script runs when the mouse button is released |
onkeydown | In this case the script runs when the key is pressed from the keyboard |
onkeypress | In this case the script runs when a key is pressed and released from the keyboard |
onkeyup | In this case the script runs when the key is released from the keyboard |
Standard attributes supported by the <a> tag-
Attribute | Description |
---|---|
accesskey | It is used to specify a keyboard shortcut to access an element |
class | It is used to specify the classname for an element |
dir | It is used to specify the text direction of the content in an element |
id | It is used to specify the unique id of an element |
lang | It is used to specify the language code of the content in an element |
style | It is used to specify an inline style of an element |
tabindex | It is used to specify the tab order of an element |
title | It is used to specify an extra information about an element |
Example-
<html>
<body>
<a href="http://www.google.com">Google</a>
</body>
</html>
Toggle Sidebar