Computer >> Computer tutorials >  >> Programming >> HTML

HTML <a> Tag


The <a> element in HTML is used to link one page to another with a hyperlink. An unvisited link is blue, visited link is purple, whereas an active link is red. All these links appear like this on a web browser and are underlined. You can link an external web page or a local page.

Following are the attributes −

Attribute
Value
Description
charset (deprecated)
character_encoding
Defines the character encoding of the linked document.
cords (deprecated)
if shape = "rect" then coords = "left, top, right, bottom"
if shape = "circ" then coords = "centerx,centery,radius"
if shape = "poly" then coords = "x1, y1, x2, y2,..,xn,yn"
Specifies the coordinates appropriate to the shape attribute to define a region of an image for image maps.
download
filename
This downloads the target when user clicks on the hyperlink.
href
URL
Specifies the URL of a page or the name of the anchor that the link goes to.
hreflang
language_code
Language code of the destination URL.
media
media_query
It specifies what media the linked document is optimized for
name (deprecated)
section name
Marks an area of the page that a link jumps to.
rel
alternate
designates
stylesheet
start
next
prev
contents
index
glossary
copyright
chapter
section
subsection
appendix
help
bookmark
Describes the relationship between the current document and the destination URI.
rev (deprecated)
alternate
designates
stylesheet
start
next
prev
contents
index
glossary
copyright
chapter
section
subsection
appendix
help
bookmark
Specifies the relationship between the target URL and the current document.
shape (deprecated)
rect
rectangle
circ
circle
poly
polygon
Specifies the shape of the image map
target
_blank
_parent
_self
_top
Where to open the target URL.
_blank - the target URL will open in a new window.
_self - the target URL will open in the same frame as it was clicked.
_parent - the target URL will open in the parent frameset.
_top - the target URL will open in the full body of the window.
type
mime_type
Specifies the MIME (Multipurpose Internet Mail Extensions) type of the target URL

Let us now see an example to implement a tag in HTML−

Example

<!DOCTYPE html>
<html>
<body>
<h2>Coding Ground</h2>
<h3>Compilers for Programming Languages and Web Technologies</h3>
<nav>
   <a href="/compile_java_online.php">Java</a> |
   <a href="/php_terminal_online.php">PHP</a> |
   <a href="/online_jquery_editor.php">jQuery</a> |
   <a href="/compile_c_online.php">C</a> |
   <a href="/compile_cpp_online.php">C++</a> |
   <a href="/online_angularjs_editor.php">AngularJS</a>
</nav>
</body>
</html>

Output

HTML <a> Tag