This time I will show you how to use the anchor point in the html web page, what are the precautions for using the anchor point in the html web page, the following is a practical case, let's go together take a look.
Anchor point is a type of hyperlink in web page production, also called named anchor. A named anchor is a hyperlink within a page, like a quick locator, and is quite commonly used.
English name: anchor
Use named anchors to set tags in the document. These tags are usually placed at or at the top of a specific topic in the document. Links to these named anchors can then be created that quickly take visitors to the designated location.
The process of creating a link to a named anchor is a two-step process. First, create a named anchor, and then create a link to the named anchor.
Sample code
Define the following anchor point at the appropriate location in the HTML page:
<a name="top">这里是TOP部分</a> <a name="content">这里是CONTENT部分</a> <a name="foot">这里是FOOT部分</a>
(You can use the id attribute to replace the name attribute, and the naming anchor is the same Valid. [1])
There are two ways to access the above anchor points
One is to use the hyperlinktag to create an anchor link. Used for anchor point access within the page
<a href="#top">点击我链接到TOP</a> <a href="#content">点击我链接到CONTENT</a> <a href="#foot">点击我链接到FOOT</a>
Another way is to add the anchor point mark directly after the page address, mainly used for anchor point access between different pages
If this page The address is http://file path/index.html. To access the foot anchor point, just access the following link
http://file path/index.html#foot
2.html What is the anchor point? What for?
To put it simply, for example, if you want to read a long article accurately by segment, you can use anchor points.
Code:
<a href="#001">跳到001</a> ...文字省略 <a name="001" id="001" ></a> ...文字省略
In fact, the anchor point only needs name. The id is added to make it more compatible.
The value of href must be consistent with name \ i d, as shown above "#" must be added. The above code is compatible in ie6/7 and ff, but not in ie8.
Because the value of our anchor point is empty, we can just add a space so as not to affect the appearance.
The following code will be compatible with ie8
<a href="#001">跳到001</a> ...文字省略 <a name="001" id="001" > & n b s p </a> ...文字省略
Another question, do you want to display the anchor content of a certain page (such as: 123.html)?
The code is as follows
<a href="123.html#001">跳到001</a> ...文字省略 <a name="001" id="001" > & n b s p </a> ...文字省略
This is yesterday when I was working on the background. I wanted to implement "modify positioning", so I moved the anchor mark out (usually it is forgotten by me).
But the program said that to get the value, there must be "?" or "&" in the connection, so my anchor point will be incompatible...
Haha! There will be a solution in the future!
Although there is a problem with anchor point compatibility in jsp pages, there is no problem in static pages, and it is still worth learning!
3. In WEB development, page anchors will be used. HTML page anchors are used to link to a section of a page. W3School says that creating anchors uses the (anchor) tag and the name attribute, but this is not the only way to create page anchors. Let’s briefly talk about two ways to make HTML page anchors.
We can use W3School's online testing tool to conduct testing. The test code after opening the link uses and , and there is no problem in the test. Then change " Explanation, in addition to using the name attribute of the anchor tag when making a page anchor, you can also use the id attribute. The value of the href attribute in the anchor tag is the beginning of # plus the value of the target's name or id:
Copy code
The code is as follows:
<html> <body> <p> <a href="#method1">页面锚点方法一</a> </p> <p> <a href="#method2">页面锚点方法二</a> </p> <h2 id="a-nbsp-name-method-方法一-a"><a name="method1">方法一</a></h2> <p>使用锚标签的 href 和 name 属性</p> <h2 id="方法二">方法二</h2> <p>使用锚标签和 id 属性</p> </body> </html>
I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!
Related reading:
What are the symbols that mark text comments in Html
How to implement an HTML-like command line interface
html+css+javascript How to implement list circular scrolling
The above is the detailed content of How to use anchors in html web pages. For more information, please follow other related articles on the PHP Chinese website!

Self-closingtagsinHTMLandXMLaretagsthatclosethemselveswithoutneedingaseparateclosingtag,simplifyingmarkupstructureandenhancingcodingefficiency.1)TheyareessentialinXMLforelementswithoutcontent,ensuringwell-formeddocuments.2)InHTML5,usageisflexiblebutr

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.


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

Dreamweaver CS6
Visual web development tools

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
