This article mainly introduces the tutorial on using hyperlink tags in XHTML, including an introduction to the usage of anchor links and link relative addresses. Friends in need can refer to
Hyperlinks, also called " Link". Hyperlinks can be said to be everywhere on the web pages we browse. When we click on a link address on a web page, it links to another web page. This is how hyperlinks work.
Use the tag to define a hyperlink, syntax:
Displayed text or image
Example:
XML/HTML CodeCopy content to clipboard
<a href="http://www.baidu.com/">链接至百度</a>
Browser display effect:
Link to Baidu
When we click on the words "Link to Baidu" above, the browser will redirect to the Baidu homepage.
Hyperlink attribute
Hyperlink attribute:
href link address. It can be an absolute web address or a relative address.
target Link target. A value of _blank will open the link address in a new window. By default, the current window will be used to open the link address.
name Anchor link, we will talk about this separately below.
Relative web link address:
XML/HTML CodeCopy content to clipboard
<a href="/css" target="_blank">p+CSS教程</a>
This example uses a relative address, while the example linking to Baidu above uses an absolute address.
Example of added target attribute:
XML/HTML CodeCopy content to clipboard
<a href="http://www.baidu.com/" target="_blank">链接至百度</a>
When you click the link again, the browser will enable a new page to open the link address, while the original page window will be retained.
Tip
When a link address is not very closely related to the current topic or process, the target="_blank" attribute is usually enabled. Otherwise, try not to open new windows in order to provide viewers with a friendly browsing experience.
If the page is composed of several page frames, the target attribute can also have other values
Email hyperlink
Email link example:
XML/HTML CodeCopy content to clipboard
<a href="mailto:admin@xyz.com">联系xyz站的站长</a>
Clicking this link will enable your default email client to compose your email.
Anchor link
Anchor link refers to the link within the page, but now many people also call text hyperlinks anchor links.
Let’s take an example to explain the role of anchors:
For example, we have a well-written article, and many people have commented after the article, and the window for commenting is usually at the bottom of the comment. Location. The website will set an anchor link where the comment is posted, and design a link to the anchor link where the comment is displayed, such as: "Post a comment." If someone does not want to view the comments left by others and wants to jump to the comment input window immediately, then click "Post a Comment" to quickly jump to the comment input window within the industry. This design undoubtedly improves the user experience for viewers.
Example of using anchor links
Create anchor:
XML/HTML CodeCopy content to clipboard
<p><a name="comment"></a></p>
Create a hyperlink address linking to the anchor:
XML/HTML CodeCopy content to clipboard
<p><a href="#comment">链接至comment锚</a></p>
As you can see from the example, to access an anchor, just add the "#" sign and the name of the anchor after the link address. In the above example, since it is an anchor linking to this page, the previous link address is ignored (note: the relative address is actually ignored, and will not be discussed here).
Tip
If you want to experiment with the use of this anchor tag, be careful to combine the hyperlink that links to the anchor with the anchor tag. Only by maintaining enough web page space can you see the effect. You can use the line break tags we learned above to create enough white space above and below to test.
You can also create an anchor tag that links to other pages, for example:
XML/HTML CodeCopy content to clipboard
<p><a href="http://www.abc.com/#test">链接至锚</a></p>
Of course, the page www.abc.com needs to have this test anchor tag, otherwise it will only link to the www.abc.com page and ignore this anchor Tag
【Related Recommendations】
2. Picture and text explanation of HTTP Headers knowledge points
3. Introduction to how to display JSON data in html
4. htmlDetailed explanation of the example of implementing the quantity subscript on the message button
5. HtmlJquery code example to complete asynchronous upload of files
The above is the detailed content of Detailed explanation of examples of hyperlinks in XHTML. For more information, please follow other related articles on the PHP Chinese website!

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
