Basic Syntax of the HTML anchor
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<a href="URL">Link Text</a>
</body>
</html>
For Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<a href="https://www.example.com">Visit Example</a>
</body>
</html>
Linking to Different Resources
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<a href="https://www.google.com">Google</a>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<a href="mailto:someone@example.com">Send Email</a>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<a href="tel:+1234567890">Call Us</a>
</body>
</html>
Target Attribute
_self: This value of the target attribute opens the link in the same tab or window and is the default value of the anchor.
_blank: Opens the link in a new tab or window.
_parent: Opens the link in the parent frame.
_top: Opens the link in the full window.
Example of opening a link in a new tab:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<a href="https://www.example.com" target="_blank">Visit Example</a>
</body>
</html>
Title Attribute
title
attribute provides additional information about the link, which is displayed as a tooltip when the user hovers over the link.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<a href="https://www.example.com" title="Click to visit Example">Visit Example</a>
</body>
</html>
Anchor Links
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML TUTORIAL</title>
</head>
<body>
<a href="#testimonial">Go to Section 1</a>
<div id="testimonial">
content...
</div>
</body>
</html>