Tuesday, October 3, 2023

HTML Links

                                         HTML Links

Links are found in nearly all web pages. Links allow users to click their way from page to page.

HTML Links — Hyperlinks

HTML links are hyperlinks.

You can click on a link and jump to another document.

When you move the mouse over a link, the mouse arrow will turn into a little hand.

HTML Links — Syntax

The HTML <a> tag defines a hyperlink. It has the following syntax:

<a href="url">click here</a>

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

The click here is the part that will be visible to the reader.

Clicking on the click here , will send the reader to the specified URL address.

Example

This example shows how to create a link:

<!DOCTYPE html>
<html>
<head>
<title>
My website

</title>

</head>
<body>

<a href="https://medium.com">
click me
</a>

<br>

<a href = "lyrics.html">
song lyrics
</a>

<br>

<a href="test@fake.com">
email me
</a>


</body>


</html>

This is how a new webpage opens with three hyperlinks:

Hyperlinks

By default, links will appear as follows in all browsers:

  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red

HTML Links — The target Attribute

By default, the linked page will be displayed in the current browser window. To change this, you must specify another target for the link.

The target attribute specifies where to open the linked document.

The target attribute can have one of the following values:

  • _self - Default. Opens the document in the same window/tab as it was clicked
  • _blank - Opens the document in a new window or tab
  • _parent - Opens the document in the parent frame
  • _top - Opens the document in the full body of the window

Example

Use target=”_blank” to open the linked document in a new browser window or tab:

<!DOCTYPE html>
<html>
<head>
<title>
My website

</title>

</head>
<body>

<a href="https://medium.com"
target ="_blank"
title = "Goes to google">

click me</a>

<br>
</body>
</html>

So, the new webpage opens after clicking on the hyperlink:

No comments:

Post a Comment

Building Static Website(part6) HTML Lists

  Building Static Website (part6) HTML Lists Today, let us add some lists to our detailed view section by using html lists. Lists: List is a...