What are the hyperlinks in HTML
The internet wouldn’t have much functionality if you could only look at one web page at a
time. To ease the ability of users to move about your website and to visit related pages of
interest we need to add hyperlinks to our html documents. This is done with the hyperlink
tag.
Oddly the hyperlink tag is denoted with the letter a. The letter a is used because it means
anchor text. Hence the <a> tag defines a hyperlink which will open a new web page when
the user clicks on it. As you probably know hyperlinks are displayed to the user as
underlined text, with blue color for a page they have not opened before and purple for web
pages they’ve already visited.
Several attributes can be specified with the hyperlink tag. The most important is the href
attribute which tells the browser which link to open when the user clicks on the text. So
href is just the url of the target web page.
HTML 5 introduces some new attributes. For example, you can use download to tell the
browser to begin downloading a file when the user clicks on the link.
The target specified in the href attribute can be a local file (relative to the web page) or
any URL. The syntax you will use is:
<a href=“url to open”>Text displayed to user</a>
The text displayed to the user can be anything, most web page developers put descriptive
text that makes it more readable and more amenable to search engines. But you can just
put the URL there if desired. These days people automatically know that underlined blue
text is a hyperlink so putting descriptive text is preferred.
Here is an example that will display a link to the New York Times website:
<body>
Hello World!
<br>
<a href=“https://ajayofficialwebsite.com”>New York Times</a>
<br>
This looks like so:
Hello World!
New York Times – set the link my blogger website
If we wanted to just display the actual link to the user, we could write:
<body>
Hello World!
<br>
<a href=“ https://ajayofficialwebsite.blogspot.com”> https://ajayofficialwebsite.blogspot.com</a>
<br>
Then we would get:
Hello World!
https://ajayofficialwebsite.blogspot.com
Now suppose you want to open a file on your own server. Consider the case of a web page
named about.html in your same directory. Then you would write:
<body>
Hello World!
<br>
<a href=“about.html”>About Us</a>
<br>
If the file was in a folder called “Info” you’d write:
<body>
Hello World!
<br>
<a href=“about.html”>/Info/About Us</a>
<br>
Often links are placed in the middle of a text string, for example:
Here is some more text linking to <a href=“https://ajayofficialwebsite.blogspot.com”>cable news
network</a> find out what the latest news is.
This displays as:
Here is some more text linking to cable news network ( --set the links ) find out what the
latest news is.