1.<a>
(Anchor Tag):
<a>
tag is used to create hyperlinks, which allow users to navigate to other web pages or resources by clicking on the linked text or image.<a>
tag is href
(hypertext reference), which specifies the URL of the linked resource.<a>
tag to link to other web pages, external websites, local files, email addresses, and more.Example:-
<a href="https://www.example.com">Visit google.com</a>
In this example, the <a>
tag creates a hyperlink that, when clicked, takes the user to the "https://www.google.com" web page.
The<a>
tag can also be used with an optionaltarget
attribute to control how the linked resource is displayed (e.g., in a new browser window or tab). For example:
<a href="https://www.google.com" target="_blank">Visit google.com in a new tab</a>
2. <img>
(Image Tag):
<img>
tag is used to embed images in web pages. It allows you to display images on a web page by specifying the image file's source (URL).<img>
tag is src
(source), which specifies the URL of the image file.alt
attribute to provide alternative text for the image. This text is displayed if the image cannot be loaded or if a user is using a screen reader.In this example, the <img>
tag embeds an image from the file "image.jpg" and provides alternative text.
You can also specify other attributes to control the image's width, height, alignment, borders, and more. For instance:
<img src="image.jpg" alt="An example image" width="200" height="150" border="1" align="right">
These attributes control the image's dimensions, border, and alignment.
Both the <a>
and <img>
tags are widely used in web development to create hyperlinks and display images, respectively. They are essential for enhancing the interactivity and visual appeal of web pages.
Result:-