html settings a

WBOY
Release: 2023-05-16 09:53:37
Original
938 people have browsed it

HTML setting a tag

The a tag is one of the most commonly used tags in HTML. Its function is to create a link that allows users to click on the link to access another web page, download a file, or send an email. Wait for operations. The basic syntax of a tag is as follows:

<a href="链接地址">链接文本</a>
Copy after login

Among them, the href attribute specifies the URL address of the target resource of the link, and the link text is the visible link text, that is, the text content that the user sees on the page.

Common a tag usage scenarios include:

  1. Jump to another web page

    <a href="http://www.example.com">跳转到Example</a>
    Copy after login
  2. Download file

    <a href="http://example.com/file.docx">下载word文档</a>
    Copy after login
  3. Send Email

    <a href="mailto:example@example.com">联系我们</a>
    Copy after login

In addition to the basic syntax, the a tag has many attributes that can be set. Some of the commonly used ones will be introduced below. Attributes.

  1. target attribute
    The target attribute specifies where the link's target is displayed. The following are common values ​​for the target attribute:
  • _self: the new link will be displayed in the current window or frame
  • _blank: the new link will be displayed in a new window or new tab Display
  • _parent in
  • _parent: New links will appear in the parent frame of the window where the link is located
_top: New links will appear in the top window in all frames

    For example, the following code will open the Example page in a new tab.
  1. <a href="https://www.example.com" target="_blank">打开Example</a>
    Copy after login

  2. rel attribute
The rel attribute specifies the link relationship, such as nofollow, noopener, noreferrer, etc. These attributes help search engines understand how well your page is linked.
  • nofollow: Inform search engines not to follow the link and exclude it from link analysis
  • noopener: Prevent the page from stealing the original when it is opened in a new tab Page data
noreferrer: Prevent the HTTP Referer header information from being leaked when the page jumps

    The following is a sample code using the rel attribute:
  1. <a href="http://www.example.com" rel="nofollow">Example</a>
    Copy after login

  2. title attribute
The title attribute specifies the text information displayed when the mouse hovers over the link. This helps users understand what the link does or is about.
  1. <a href="http://www.example.com" title="前往Example">Example</a>
    Copy after login

  2. download attribute
The download attribute is a new attribute in HTML5, which specifies that the linked resource needs to be downloaded or saved. When the user clicks on the link, the browser will prompt for file download or download the file directly.

<a href="http://example.com/file.docx" download>下载</a>
Copy after login

When setting the download attribute, you can specify the downloaded file name:

<a href="http://example.com/file.docx" download="mydoc.docx">下载</a>
Copy after login
###The above are some commonly used a tag attribute setting methods. It should be noted that when setting the a tag, special attention should be paid to the authenticity and reliability of the target address of the link, as well as the correlation between the link text and the target content, to prevent problems such as misleading users or guiding users to visit malicious websites. ###

The above is the detailed content of html settings a. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!