chevron_left
2,504 points
20 16 12

Today we are going to learn how to create an HTML link that opens in a new tab.

As you probably already know - and if not, I'll tell you - a normal link in HTML has the following basic structure:

<a href =" URL "> Text </a>

That link, by default, will open in the same tab where you are.

To change this and open the link in a new tab, you have to include a target, which in HTML would consist of adding the command target = "_ blank"  just after the URL (to be exact, after the English quotes and space). Let's see:

2. HTML CODE TO OPEN A LINK IN ANOTHER TAB

The general structure to  create an HTML link that opens in a new tab  would be the following ( the parts that you must customize in red: the destination URL and the visible text that the link will have ):

<a href =" URL "target="_blank"> text </a> 

3. SAMPLE HTML CODE TO OPEN A LINK IN A NEW TAB

To show you an example, I am going to create a link to the category where I have posted similar to the one you are reading.

This would be our line in HTML:

<a href =" https://www.kodlogs.com/programming/web-pages/ "target="_blank"> Keep learning in our #web section! </a>

And it would look like this:

Keep learning in our #WEB section!

 

4. SIMPLE? ANY QUESTIONS?

I hope the information has been useful to you. Any doubt or contribution that you want to share, you can leave in the comments.

See you soon! 

More Posts

How to open a tab in a new window amna - Jun 29
How to open link in a new tab amna - Jun 29
How can you open a link in a new tab/browser window Sanjana Sagar - May 22
How to make a picture a link html amna - Jun 30
how to link a word document in html? videepsinghal - Aug 22
How to Put a link in Paragraph HTML? videepsinghal - Aug 11
How to change a color of the link in HTML? videepsinghal - Aug 10
How to remove underline from link in html amna - Feb 7
How to link two pages in html amna - Dec 4, 2020
How to link submit button to another page in HTML Prasandeep Gautam - Oct 17, 2020