The "anchor" tag
The most important attribute of the <a> tag is the href attribute, which indicates the link's destination.
By default, links will appear in all browsers as follows:
- An invisited link is underlined and blue
- A visited link is underlined and purple
- An active link is underlined and red
The <a> supports many attributes.
1. download attribute:-
The download attribute is a boolean attribute or has an optional attribute value for the attribute download which specifies the name of the downloaded file.
It specifies the target of the hyperlink which is specified in the href is download when the user clicks on the hyperlink.
Example:
<a href="images/example.jpg" dowmload>Click here</a>
. The file example.jpg will be downloaded when the user clicks on "Click me".
To specify the name of the downloaded file use this code snippet.
<a href="images/test.jpg" download="myname.jpg">Click here</a>
. When the user clicks on "Click me", the file test.jpg will be downloaded and saved with thename "nyname.jpg"
2. href attribute:-
The href attribute specifies the URL of the page the link goes to.
3. target attribute:-
The target attribute specifies where to open the linked document.
Possible values for the target attribute are as follows:-
1. _blank - Opens the linked document in a new window or tab
2. _self - Opens the linked document in the same frame as it was clicked (this is default)
3. _parent - Opens the linked document in the parent frame
4. _top - Opens the linked document in the full body of the window
5. framename - Opens the linked document in the named iframe
Example:
1. Open link in a new window or tab:
<a href="https://thewebdesk.blogspot.com/2023/02/html5-blockquote-element.html" target="_blank">Click me</a>
An anchor tag has four states
- The first state is that it is not visited even once
- The second state is that it mouse is just pressed doen
- THe third state is that the user has hovered the mouse over the link
- The fourth state is that the mouse is pressed and released and hence the link has been visited
Comments
Post a Comment