HTML link: Use a hyperlink to connect to another document on the web

HTML link


HTML uses hyperlinks to connect to another document on the web. You can find links on almost all web pages. Click the link to jump from one page to another.


 

How to create links in HTML documents.

(You can find more examples at the bottom of this page)


HTML hyperlink (link)

HTML uses the tag <a> to set up hypertext links.

The hyperlink can be a word, a word, or a group of words, or it can be an image. You can click these contents to jump to a new document or a part of the current document.

When you move the mouse pointer over a link on a webpage, the arrow changes to a small hand.

The href attribute is used in the tag <a> to describe the link address.

By default, the link will appear in the browser in the following form:

  • An unvisited link is displayed in blue font and underlined.
  • Visited links are displayed in purple and underlined.
  • When you click on a link, the link is displayed in red and underlined.

Note: If CSS styles are set for these hyperlinks, the display style will be displayed according to the CSS settings.


HTML link syntax

The HTML code for the link is simple. It looks like this:

<a href=" url "> link text </a>

The href attribute describes the target of the link. .

Examples

<a href="https://www.runoob.com/"> visit rookie tutorial </a>

 

Clicking on this hyperlink will take the user to the homepage of the rookie tutorial.

Tip: "Link text" does not have to be text. Pictures or other HTML elements can become links.


HTML link-target attribute

Using the target attribute, you can define where the linked document is displayed.

The following line will open the document in a new window:

Examples

< A href = " https://www.runoob.com/ " target = " _blank " rel = " noopener noreferrer " > visit rookie tutorial! </ A >


 


HTML link-id attribute

The id attribute can be used to create bookmark tags in an HTML document.

Tip: Bookmarks are not displayed in any special way, and are not displayed in HTML documents, so they are hidden from readers.

Examples

Insert ID in HTML document:

<a id="tips"> Useful tips section </a>

Create a link to the "useful tips section (id =" tips ")" in the HTML document:

<a href="#tips"> Access useful tips section </a>

Or, create a link from another page to "useful tips section (id =" tips ")":

<a href="https://www.runoob.com/html/html-links.html#tips">
access useful tips section </a>

 


Basic notes-useful tips

Note: Always add forward slashes to subfolders. If you write a link like this: href = "https://www.runoob.com/html", two HTTP requests will be made to the server. This is because the server will add a forward slash to this address, and then create a new request, like this: href = "https://www.runoob.com/html/".

 

HTML link tags

label description
<a> Define a hyperlink

Guess you like

Origin www.cnblogs.com/peijz/p/12724154.html