Open a different tab for each link

Asked

Viewed 55 times

1

Hello!

I’m starting to learn HTML now and I came across the following situation: when selecting one of the body links open a new tab and when selecting the other link opens a new tab that replaces the previous one.

The behavior you would like to play is that each clicked link opens a new tab.

How can I do this using html?

Note: Any tip or good practice instruction is welcome.

Below is an example code I’m using.

<!DOCTYPE html>

<html>

    <head>
        <meta charset = "UTF-8">
        <title>Exemplo 04</title>
        <link rel="icon" type="image/png" href = "icone.png"/>
        <base href = "http://www.w3c.org/"/>
        <base target="_blank/"/>
        
        <style type="text/css">
            body{
                background-color: lightpink;
            }
            
            p{
                color: green;
            }
        </style>
    </head>
    
    <body>
        <h1>Título do conteúdo</h1>
        <p>Link - padrões: <a href="/standards/">link</a></p>
        <p>Link - google: <a href="http://www.google.com">link</a></p>
    </body> 


</html>

Thanks in advance!

  • Take a look here that can help you: https://answall.com/questions/349963/diferen%C3%a7a-entre-Blank-self-e-Blank-self

2 answers

3

Hey, how you doing? I’m also new to HTML 5 but I think I know the answer. To open the link in a new tab, just add the attribute target="" within the tag <a>, in this way:

<p>Link - padrões: <a href="/standards/" target="_blank">link</a></p>

In this case, we fill the target with _Blank to open the link in a new tab in white (I think that’s where the name came from). The default if you do not specify and do not put _Blank, is the _self, where the link opens on the same page.

I use Vscode to program and it already shows the various functionalities within the attribute target="", but I found an article in English that talks about it: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/target

This Mozilla website is very good (https://developer.mozilla.org/en-US/), I recommend because in addition to good documentation, there are some documents in Brazilian Portuguese. Anyway, there are a few more uses for this attribute, but I think what you’re wanting to do is this. I hope I’ve helped!

0

Hello, good afternoon, sir! Just add it inside your tag <a> the attribute target="Blank", thus:

  <p>Link - padrões: <a href="/standards/">link</a></p>

This way you are telling the browser that when you click the hyperlink you target (target) a new blank tab (Blank).

Your code should look like this:

<!DOCTYPE html>

<html>

    <head>
        <meta charset = "UTF-8">
        <title>Exemplo 04</title>
        <link rel="icon" type="image/png" href = "icone.png"/>
        <base href = "http://www.w3c.org/"/>
        <base target="_blank/"/>
        
        <style type="text/css">
            body{
                background-color: lightpink;
            }
            
            p{
                color: green;
            }
        </style>
    </head>
    
    <body>
        <h1>Título do conteúdo</h1>
        <p>Link - padrões: <a href="/standards/" target="blank">link</a></p>
        <p>Link - google: <a href="http://www.google.com" target="blank">link</a></p>
    </body> 


</html>

I hope I’ve helped!

Good studies!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.