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:
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!