HTML Links

What is Links in HTML?

Links allow users to click their way from page to page.

Note: A link does not have to be text. A link can be an image or any other HTML element!


HTML Links Syntax:

Let's see the syntax how you can create link in html.

                          
                            <a href="url">link text</a>
                          
                        

Let's see Example:

                          
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Visit Learn Fasta</title>
  <style>
    body {
      font-family: 'Arial', sans-serif;
      text-align: center;
      margin-top: 50px;
      font-size: 18px;
    }
    a {
      text-decoration: none;
      color: #3498db; /* Blue color for the link */
      font-weight: bold;
    }
    a:hover {
      text-decoration: underline;
    }
  </style>
</head>
<body>
  <a href="https://example.com/">Visit Example Website</a>
</body>
</html>
                          
                        

Target Links

target attribute specifies where to open the linked document.

In your attribute(a href="url" target="_blank") you can add target="_blank"


Target Links syntax:

                          
                            <a href="url" target="_blank">link text</a>
                          
                        

Link to an Email Address

Use mailto: inside the href attribute to create a link that opens the user's email program


Link to an Email Address syntax:

                        
                          <a href="mailto:someone@example.com">link text</a>
                        
                      

Let's see Example:

                        
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Visit Learn Fasta</title>
  <style>
    body {
      font-family: 'Arial', sans-serif;
      text-align: center;
      margin-top: 50px;
      font-size: 18px;
    }
    a {
      text-decoration: none;
      color: #3498db; /* Blue color for the link */
      font-weight: bold;
    }
    a:hover {
      text-decoration: underline;
    }
  </style>
</head>
<body>
  <a href="mailto:example@gmail.com">Learn fasta</a>
</body>
</html>