Links in HTML:
Links in HTML:
The link provides the facility to transfer the call of one page to another. Web pages are linked together with the help of the link. Generally, Hyperlinks are links in Html. While clicking on that link You can jump from one page to another. You can detect the link with the help of a mouse when you hover.
Syntax:
<a href=”url“>content</a>
Links are defined by <a> tag which is also called anchor tag.
Example:
<!DOCTYPE html>
<html>
<body>
<h1>hello</h1>
<p><a href="http://dreamzdevelopers.com/wp-content/uploads/2020/10/TND_M88_02-370x250.jpg">Visit google.com</a></p>
</body>
</html>
Inside <a> href attribute is there which accept URL inside it. While clicking on the link we will switch to another page.
Note:
– The unvisited link will be in blue and underlined
– The visited link will be in purple and underlined
– The active link will be red color and underline
Absolute vs relative URL:
The absolute link consists of the full address, the entire location of a file, where a relative link will be called when we need to access a file inside the same website.
Example:
<p>Absolute urls in html</p>
<p><a href="dreamzdevelopers.com">dreamsdeveloper</a></p>
<p><a href="dreamzdevelopers.com">dreamsdeveloper</a></p>
<p>Relative URLs</p>
<p><a href="hdtd_images2.png">HTML Images</a></p>
<p><a href="/images/mushroom.jpg">Images stuff</a></p>
Image links:
In order to use image as link You have to use <img> inside <a> tag.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>Image as a Link</h2>
<a href="www.dreamzDevelopers.com"><img src="http://dreamzdevelopers.com/wp-content/uploads/2020/10/TND_M88_02-370x250.jpg" alt="link with image" style="width:2px;height:2px;"></a>
</body>
</html>
Button link in HTML:
To use the button link you should use JavaScript inside HTML code.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>click the button</h2>
<p>HTML tutorial to learn html.</p>
<button onclick="document.location='Hello.asp'">HTML leaning</button>
</body>
</html>
Target Attribute in HTML:
If you want to switch the clicked link to a new tab of the browser then you must use the target attribute inside the <a> tag.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>Namaste indians</h2>
<a href="http://dreamzdevelopers.com//" target="_blank">Visit dreamzdeveloper</a>
</body>
</html>
