search
HomeWeb Front-endHTML TutorialDetailed explanation of examples of hyperlinks in XHTML

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>
  1. Browser display effect:

  2. Link to Baidu

  3. 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>
  1. 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>
  1. 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.

  2. Tip

  3. 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.

  4. 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>
  1. 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>
  1. Create a hyperlink address linking to the anchor:

XML/HTML CodeCopy content to clipboard

<p><a href="#comment">链接至comment锚</a></p>
  1. 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).

  2. Tip

  3. 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.

  4. 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】

1. HTML Free Video Tutorial

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!

Statement
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
HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.