Paths in HTML

You can find links (links) throughout the web. Link allows clicking to switch to another page.

You can find links (links) throughout the web. Link allows clicking to switch to another page.

What is the path in HTML

The paths in HTML are hyperlinks. Clicking on it will take you to another document. When hovering over the path, the mouse's arrow icon changes to a hand icon.

Note: The path is not necessarily text, it may be an image or other HTML elements.

Syntax path in HTML

In HTML, the path is defined by the tag

 href = "url"> text for the path 

For example

 href = "https://www.quantrimang.com/html/"> Summary of HTML lessons 

The href attribute is used to determine the address of a specific destination. (Https://quantrimang.com/html/) The text for the path is the part that will be displayed, clicking here will take you to that address.

Note: If you do not use a slash for the subdirectory address, it may create 2 requests to the server. Many servers automatically add a dash to create a request.

Local Link local path

The example above uses the URL for both the website, the internal link (link to the same website) specified by the relevant URL (no need to https: // www.)

 href = "html_images.asp"> HTML images 

HTML path colors

By default the link will appear as follows (on all browsers)

  1. Unused / clicked links (unvisit) are blue and underlined
  2. The path has been visited / clicked on (visit) purple and underlined
  3. The active (red) path is red and underlined

You can change the default color with CSS.

For example

 le> le> 
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}

a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}

a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}

a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}

Thuộc tính target Target attribute

Thuộc tính target dùng để xác định xem sẽ mở văn bản được liên kết đó ở đâu, có thể là các giá trị sau: The target attribute is used to determine where the linked text will be opened, which can be the following values:

_blank opens in a new window or tab
_self opens at the same window / tab (default)
_parent opens in the parent frame
_top open in the entire window
framename opens in the naming frame (named frame)

The following example opens the text in the new window / tab

 href = "https://www.quantrimang.com/" target = "_ blank"> Access Network Administrator 

If the site is closed in the frame, you can use target='_top' to break the frame.

 href = "https://www.quantrimang.com/html/" target = "_ top"> HTML5 Tutorial 

Path as image

 a href="default.asp"> 
Learn HTML
style="width:42px;height:42px;border:0;">
>

border:0' is added to prevent IE9 (and backwards) from showing the border around the image (when the image is a path).

Path title

The title attribute is used to specify additional information for the element. Information is usually displayed in the form of tooltip when pointing over the element.

 href = "https://www.quantrimang.com/html/" title = "Access HTML learning page"> HTML learning page 

Create bookmark

Bookmarking in HTML is used to make it easier for readers to go to other parts of the site. Bookmarking is useful when the webpage is too long.

You must first create a bookmark and then add the path to it. When clicking on the link, the page will scroll to the address that bookmarked it.

Create a bookmark with the id attribute

id = "C16"> Chapter 16

Then add the path to the bookmark (Go to Chapter 16) from the same page

 Go to Chương 16 

Attach the path to the bookmark (Go to Chapter 16) from another page

 href = "html_demo.html # C4"> Go to Chapter 16 

External path

The external path may refer to the URL or the link associated with the current website. The example below uses the full URL.

 href = "https://www.quantrimang.com/html/default.asp"> HTML Tutorial 

The example below leads to the website in the HTML directory of the same website

 href = "/ html / default.asp"> HTML Tutorial 

The example below leads to the site located in the same directory of the same current page

 href = "default.asp"> HTMLl Tutorial 

Previous article: Style for HTML with CSS

The following article: Images in HTML

4 ★ | 1 Vote