Introduction To Web Design
Introduction To Web Design
ITC 122
HYPERLINKS
Hyperlinks, or simply links, are an important element of the web, connecting one webpage to another.
This ability to link between pages is what distinguishes HTML from most other markup languages.
HTML LINKS
The destination link is provided inside the href attribute, which stands for hypertext reference.
PROBLEM
The visible text of the link should be The Imitation Game - IMDb.
When clicked, this should take the user to the following URL: https://www.imdb.com/title/tt2084970/
Note: Be careful with spelling mistakes, as they can cause this practice problem to fail.
OPEN LINKS IN NEW TAB
The code above creates a link that opens in the same tab:
If we want to open the link in a new tab, we need to use the target attribute with value the _blank.
We can also use the title attribute with the <a> tag, which appears when the user hovers over the hyperlink.
For example:
<a href="https://www.arellano.edu.ph/" title="Arellano University Website">Visit Arellano University</a>
PROBLEM
Images as Links
It is also possible to use images as links.
To use images as links, simply replace the visible text of the link with an image. For example,
<a href="https://en.wikipedia.org/wiki/Bengal_tiger">
<img src="tiger.png" alt="A Bengal tiger">
</a>
When you run the code and click on the image, you will be redirected to the Wikipedia page about bengal
tigers.
…
Good example
<p>To learn coding, visit <a href="https://www.w3schools.com">W3SCHOOLS</a></p>
EXAMPLES: RELATIVE PATH
As mentioned earlier, a relative path can change depending on where the current page is located.
Suppose we have a directory structure like this
www.w3schools.com/