fbpx
Redirecting someone to another page or redirecting content to your webpage is a very good way to keep things interactive. This can be made possible by the “a tag in HTML”. Let’s understand this but first

What are tags in HTML?

HTML tags are like keywords which defines that how web browser will format and display the content. With the help of tags, a web browser can distinguish between an HTML content and a simple content. HTML tags contain three main parts: opening tag, content and closing tag. But some HTML tags are unclosed tags.

When a web browser reads an HTML document, browser reads it from top to bottom and left to right. HTML tags are used to create HTML documents and render their properties. Each HTML tags have different properties.

An HTML file must have some essential tags so that web browser can differentiate between a simple text and HTML text. You can use as many tags you want as per your code requirement.

  • All HTML tags must enclosed within < > these brackets.
  • Every tag in HTML perform different tasks.
  • If you have used an open tag <tag>, then you must use a close tag </tag> (except some tags)

What is ‘a’ tag in HTML?
A link is specified using HTML <a> tag. This tag is also known as anchor tag and anything inside this opening <a> tag and closing </a> tag becomes the part of the link and the user can just click that part and can reach to that linked content or document. This <a> is the simple tag to use and is as follows:

<!DOCTYPE html>
<html>
<head>
<title> a tag</title>
</head>
<body>
<h2> HTML Links</h2>
<a href=”https://www.google.com/” target=”_blank”> Google </a>
</body>
</html>

Output

HTML Links

Google

Options in ‘a’ Tag
You can provide a lot of options in this a tag in HTML. Below are some of them

OptionDescription
_blankA linked document is opened in a new tab or new window.
_selfA linked document is opened in the same frame.
_parentA linked document is opened in the parent frame.
_topA linked document is opened in the full body of the window.
targetframeA linked document is opened in a named targetframe.
downloadTo create a link that tells a browser to download a file

Example for the basic understanding the difference in few options given for target attribute of a tag.

<!DOCTYPE html>
<html>
<head>
<title> Link HTML</title
<base href=”<a href=”http://www.mildaintrainings.com/”>http://www.mildaintrainings.com/</a>”>
</head>
<body>
<p> Click any of the following links.</p>
<a href=”https://mildaintrainings.com/” target=”_blank”> Opens in new </a> |
<a href=”https://mildaintrainings.com/” target=”_parent”> Opens in parent </a> |
<a href=”https://mildaintrainings.com/” target=”_self”> Opens in self </a> |
<a href=”https://mildaintrainings.com/” target=”_top”> Opens in body </a> |
<a href=”https://mildaintrainings.com/images/logo.png” download=”Example_File”>download a file</a>
</body>
</html>

Output

With this, we come to an end of this a tag in HTML article. I hope you understood what an anchor tag is.

Check out our Full Stack Web Developer Masters Program which comes with instructor-led live training and real-life project experience. This training makes you proficient in skills to work with back-end and front-end web technologies. It includes training on Web Development, jQuery, Angular, NodeJS, ExpressJS, and MongoDB.

Corporate
close slider

Your Name (required)

Your Email (required)

Contact Number

Course

Location

Company

No Of Participant

Query