<a> Tag

Goal

  • âš¡ Learn how to use <a> tag

What is <a> tag ?

The <a> tag defines a hyperlink, which is used to link from one page to another.

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

https://www.w3schools.com/tags/tag_a.asp

Try <a> tag

test1.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>Here is a title.</h1>
<h2>Here is a subtitle.</h2>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<img
src="https://upload.wikimedia.org/wikipedia/commons/2/28/Tortoiseshell_she-cat.JPG"
alt="Hello this is cat image"
width="320"
height="320"
/>
<a href="https://www.google.com/">Hello Google</a>
</body>
</html>

Navigate to different file

I will show how to navigate to the different file.

Make test2.html

Let's make test2.html.

html-test/test2.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>Hello this is test2.html</h1>
</body>
</html>

Add link to test2.html in test1.html

test1.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>Here is a title.</h1>
<h2>Here is a subtitle.</h2>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<img
src="https://upload.wikimedia.org/wikipedia/commons/2/28/Tortoiseshell_she-cat.JPG"
alt="Hello this is cat image"
width="320"
height="320"
/>
<a href="https://www.google.com/">Hello Google</a>
<a href="test2.html">Go to test2.html</a>
</body>
</html>