Html Links with Example - Code4xU


  • 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.)
In Html links are generally added to webpage by using href attribute.
<a href="URL"">Linked text/image</tagname>
To link Text with Hyperink 
  Input
<Html>
<body>
<a
href="https://code4xu.blogspot.com">Visit Code4xU</a>
</body>
</html
>
  Output
Visit Code4xU
To link Image with Hyperink 
  Input
<Html>
<body>
<
href="https://code4xu.blogspot.com">
<img
src="code_logo.png"/>
</a>
</body>
</html
>
  Output
::::Target Attribute::::

The 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.
when we add a link in webpage the target attribute is set to _self even if it was not written inside html element.
<href="https://code4xu.blogspot.com">Visit Code4xU </a>
OR
<href="https://code4xu.blogspot.com" target="_self">Visit Code4xU</a>
Both are Same.

Target Attribute can have following values:-
  1. _self
  2. _parent
  3. _blank
  4. _top
::::Link Color::::

By Default, Link color is blue with a underline.It can't be changed in HTML.By using CSS properties we can not only change link color but also add so other properties of CSS.
Example

<!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>

::::Html BookMarks::::

In Most of the websites you have seen a Arrow or box that takes you at the Top of the Website.
Even on my website there is a arrow on bottom-right Corner that takes you directly on the top of the website.
Have you Ever think How it's work?
This is done by the bookmark.To create a book marks we have to use id and href attributes.
  • The id denotes the destination, where we have to go.
  • href linked the text with id element.
  • For better Understanding Lets check an Example.
Input

<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>

    <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>

Output

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]
Sajal Gupta

Hi, i am sajal.I am a hardworking engineering graduate specialised in Computer Science Engineering ... Along with my degree, I completed C/C++,.Net,Java and SQL courses From Youtube and Other sources and various technologies.I learnt helped me develop my final year project called Code4xU..

Post a Comment