16 Feb HTML a Tag
Use the HTML5 <a> tag, to add a hyperlink to an HTML Document. You need to add the href attribute, under the <a> element, to link a web page to another.
Example
The following example shows how to work with HTML <a> tag,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<!DOCTYPE html> <html> <head> <title>HTML a tag</title> </head> <body> <h2>Wikipedia Java Resource</h2> <p>Click the following link to learn Java programming language,</p> <a href="https://en.wikipedia.org/wiki/Java_(programming_language)">Learn Java!</a> </body> </html> |
Here’s the output,
Attributes
The following are the attributes of the <a> tag,
- charset
To set the character-set if the document to be linked. Deprecated Attribute.
Value: char_encoding - cords
Set the coordinates here. Deprecated Attribute.
Value: coordinates - download
The target gets downloaded on clicking the hyperlink. This is an HTML5 Attribute.
Value: filename - href
The URL of the page the link goes to
Value: URL - hreflang
The language of the linked document.
Value: language_code - media
Set the media query here for device. This is an HTML5 Attribute.
Value: media_query - name
The name of the anchor. Deprecated Attribute.
Value: section_name - rel
It is the relationship between the current and linked document. Deprecated Attribute.
Value: alternate, author, bookmark, external, help, license, next, nofollow, noreferrer, noopener, prev, search, tag - rev
It is the relationship between the linked and linked document. Deprecated Attribute.
Value: text - shape
To set the shape of the link. Deprecated Attribute.
Value: default, rect, circle, poly - target
To set where the linked document will open.
Value: _blank _parent _self _top framename - type
Set the media type of the linked document.
Value: media_type
No Comments