Questions
Write HTML Code to demonstrate the use of Anchor Tag for the Following:- 1. Creating a web link that opens in a new window. 2. Creating a web link that opens in the same window. 3. C Reference within the same html document. 4. Reference to some image. 5. Making an image a hyperlink to display second image
Last Updated : 16 Jul 2025
Jan 20, Jan 21, Jan 22, Jul 22, Jan 23, Jul 24, Jan 24
Solution:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<a href="https://www.examjila.com" target="_blank">I am new Link</a>
<a href="https://www.primegyan.com">I am same Link</a>
<a href="#myid"> with document</a>
<a href="https://examjila.com/public/assets/images/about/olevelcourse.webp"> <img src="https://examjila.com/public/assets/images/student-with-books.png"> </a>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
<h1 id="myid">im section</h1>
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.loerem
</body>
</html>
OUTPUT:
Code Explaination:
-
Anchor Tags (
<a>
):<a href="https://www.examjila.com" target="_blank">I am new Link</a>
- Links to "https://www.examjila.com" and opens in a new tab.
<a href="https://www.primegyan.com">I am same Link</a>
- Links to "https://www.primegyan.com".
<a href="#myid"> with document</a>
- Links to the element with
id="myid"
on the same page.
- Links to the element with
-
Image in Link:
<a href="https://examjila.com/public/assets/images/about/olevelcourse.webp"> <img src="https://examjila.com/public/assets/images/student-with-books.png"> </a>
- Clickable image that leads to another image when clicked.
-
Text Content:
- Contains placeholder text and a heading.
<h1 id="myid">im section</h1>
- A heading with
id="myid"
for internal linking.
- A heading with
Meanwhile you can watch this video
Watch Video