- Links plays an important role while creating a website.
- It helps to links different webpages on a single webpage.
- Links helps the user to visit on a linked webpage directly without entering a URL.
- HTML Links are Hyperlinks.(activated by clicking on a highlighted word or image.)
links
are generally added to webpage by using href attribute.<a href="URL"">Linked text/image</tagname>
<Html>
<body>
<a href="https://code4xu.blogspot.com">Visit Code4xU</a>
</body>
</html>
Visit Code4xU
<Html>
<body>
<a href="https://code4xu.blogspot.com">
<img src="code_logo.png"/>
</a>
</body>
</html>
target
attribute plays an important role in opening links.By default the linked page is opened in a same tab.By using target attribute we can control linked page opening.
<a href="https://code4xu.blogspot.com">Visit Code4xU
</a>
<a href="https://code4xu.blogspot.com" target="_self">Visit Code4xU</a>
Target
Attribute can have following values:-_self
_parent
_blank
_top
<!DOCTYPE html>
<html>
<head>
<style>
a{
color: orange;
text-decoration: none;
}
a:hover {
color: blueviolet;
background-color: transparent;
text-decoration:line-through;
}
a:active {
color: grey;
background-color: transparent;
font-weight:bold;
}
</style>
</head>
<body>
<h2>Code4xU
</h2>
<a href="https://code4xu.blogspot.com" target="_blank">Visit Us</a>
</body>
</html>
- The id denotes the destination, where we have to go.
- href linked the text with id element.
- For better Understanding Lets check an Example.
<html>
<body style="font-size:20px;">
<span>This will take you directly On </span>
<a href="#value2">Chapter 20 </a>
<p>chapter 1</p>
<p>chapter 2</p>
<p>chapter 3</p>
<p>chapter 4</p>
<p>chapter 5</p>
<p>chapter 6</p>
<p>chapter 7</p>
<p>chapter 8</p>
<p
>chapter 9</p>
<p>chapter 10</p>
<p>chapter 11</p>
<p id="value2">chapter 12</p>
<p>chapter 13</p>
<p>chapter 14</p>
<p>chapter 15</p>
<p>chapter 16</p>
<p>chapter 17</p>
<p>chapter 18
</p>
<p>chapter 19</p>
<p>chapter 20</p>
<p>chapter 21</p>
<p>chapter 22</p>
<p>chapter 23</p>
<p>chapter 24</p>
<p>chapter 25</p>
<p>chapter 26</p>
</body>
</html>
This will take you directly On [ Chapter 12 ]
chapter 1
chapter 2
chapter 3
chapter 4
chapter 5
chapter 6
chapter 7
chapter 8
chapter 9
chapter 10
chapter 11
chapter 12
chapter 13
chapter 14
chapter 15
chapter 16
chapter 17
chapter 18
chapter 19
chapter 20
chapter 21
chapter 22
chapter 23
chapter 24
chapter 25
chapter 26
Lets go On Target Attribute Directly without Scrolling [Click Here]