How to add external links to html

下次还敢
Release: 2024-04-11 06:32:44
Original
767 people have browsed it

How to add external links in HTML

External links are links to web pages or files located outside the current web page. Adding external links in HTML is very simple, here are the specific steps:

1. Use the tag

To create an external link, use the tag, This tag contains the following attributes:

  • href: Specifies the target URL of the link.
  • target: Specifies where the link opens (e.g., new tab or current page).

2. Link text

The content of the tag will become the link text, which is the clickable text that appears when the user clicks. It can be used as a word, phrase or image.

3. Example

To create a link that opens in a new tab pointing to google.com, the code is as follows:

<code class="html"><a href="https://www.google.com" target="_blank">Google</a></code>
Copy after login

4 . Using the target attribute

The target attribute allows you to specify where the link should be opened. Here are some common goals:

  • _blank: Open the link in a new tab.
  • _self: Open the link in the current page (default).
  • _parent: Open the link in the parent frame.
  • _top: Open the link in the browser's top-level window.

5. Add image links

You can also use images as links. To create an image link, use the tag and set its src attribute to the URL of the image and its href attribute to the target URL.

<code class="html"><a href="https://www.google.com" target="_blank">
  <img src="google_logo.png" alt="Google" width="200" height="60">
</a></code>
Copy after login

Tip:

  • Make sure the target URL is correct.
  • Use the target attribute correctly to control link behavior.
  • Use descriptive link text to improve user experience and SEO.

The above is the detailed content of How to add external links to html. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template