How To Add A Link To An Image Html
Introduction to Image Link in HTML
Epitome Link In HTML is institute in near all pages as they help the states navigate from one page to some other on a website. A pop combination is to use the HTML ballast tag <a> with HTML'due south img tag <img>. With this combination, we tin allow the motion of users from one page to some other by clicking on an image. Earlier nosotros dive further into this topic, let'southward first understand the working and rendering of ballast and image elements individually and then combine them to achieve a linked paradigm.
HTML Anchor Tag
The HTML Anchor tag is used to create HTML hyperlinks to other spider web pages or multimedia content hosted on the spider web. Let's refer to the syntax below to understand how anchor tags work and their basic attributes
<a href="https://www.google.co.in/">Click here!!</a>
In the above case, the "href" attribute specifies the URL of the webpage to which nosotros would similar to redirect the user while click on the text "Click here!!".
Let us encounter the complete code below :
Output
<!––>
With the above example, yous will be able to make the following observations
- An unvisited link will announced underlined and in blue colour. For, e.g. This is an unvisited Link
- A visited link will appear underlined and in regal colour. For, e.g. This is an already visited Link
- An active link appears underlined and in red color. For, e.g. This is an active Link
HTML Image Tag
While browsing the net, I am certain you must accept come across several spider web pages which have various forms of multimedia included in them. Especially images are a popular form of multimedia that can be found in almost all interactive web pages and websites today. Let us empathise the epitome tag and its implementation in HTML with the example below:
Syntax
<img src="smiley.gif" alt="Smiley face" width="42" height="42">
Let the states at present understand how each of the attributes in the img tag work:
- src: The src attribute defines the image file path nosotros are trying to load with this tag. It can be linked to an prototype hosted on the spider web with a format like example.com/images/dummy.png or an image file locally hosted on the same server as the web page.
- alt: The alt aspect defines the text and description of the image that nosotros would like to display in example if the images fail to load due to network connectivity or any other consequence.
- Width and top: The width and height of both attributes define the width and meridian of the image we'd like to display on the web page. Else the image would work with by default 100% superlative and width.
Now let's run across the complete HTML code required to load an image on a webpage. Save the following image by the proper name "dusk.png" in a binder called "image_test" in your local bulldoze.
At present in the same folder, permit's create an HTML file named sunset.html with the following HTML code :
At present go to a browser on your machine and type in the path of the .html file. My files are stored in a D bulldoze, so the path for me would exist
D:/image_test/sunset.html
And at present we can see that the rendered HTML page has loaded the sunset image on our browser. With the assist of CSS and <p> tag, we can also display text every bit per our requirement around the image. Both the anchor and img tags are compatible with all browsers like Google Chrome, Safari, Microsoft Edge, Firefox and Cyberspace Explorer.
Linked Images in HTML
At present that nosotros take understood with examples how anchor tag and image tag work individually, let us now understand how we can combine the ii functionalities to accomplish a scenario where nosotros would like the users to be redirected to a new webpage with the click of an image. To brand an image clickable and redirect the user to another webpage, we simply need to nest the image in an ballast tag. In the below example, we will attempt to enlist the superlative three spider web search engines used across the globe. In our listing, nosotros will testify the logos of the 3 search engines, and past clicking on whatsoever of the logos, the user will be redirected to the respective search engine page. Let u.s.a. create a folder named "redirection test", and in the same binder, allow'due south salve the below images
1. Google
2. Yahoo
3. Bing
Now we will create a .html by the proper noun imageredirection.html in the same file. The imageredirection.html will comprise the following code.
Now nosotros need to access the HTML page from the browser, for which I will type my local path "D:/redirectiontest/ imageredirection.html". the browser will then render the HTML file to generate the following result:
<!––>
The users will exist able to navigate to the corresponding search engine by clicking their logo. From the above example, we can observe that HTML is a unproblematic and flexible linguistic communication that allows united states to combine multiple tags together and achieve a complex functionality similar this. The combination of using img and anchor tag is a popular combination.With boosted HTML coding we can as well add different HTML elements like displaying linked images in an ordered or unordered list using <ol> or <ul>. The extreme flexibility and simplicity that HTML provides with each version released help UI and UX designers design interactive and intuitive web pages that we see while browsing the internet for day to day activities.
How To Add A Link To An Image Html,
Source: https://www.educba.com/image-link-in-html/
Posted by: howarddiseve.blogspot.com
0 Response to "How To Add A Link To An Image Html"
Post a Comment