Several common methods for setting anchor positioning in HTML

Several common methods for setting anchor positioning in HTML
There are several ways I know of to set anchor positioning in HTML, let me share them with you:

1. Use id positioning:

Copy code
The code is as follows:

<a href="#1F" name="1F">Anchor Point 1</a>
<div name="1F">
<p>
11111111111
</br>
11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>11111111111
</br>
</p>
</div>

This positioning can be targeted at any label.

2. Use name positioning:

Copy code
The code is as follows:

<a href="#5F">Anchor Point 5</a>
</br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
<a name="5F">1111111</href>

The name attribute can only be used to locate the a tag, but it cannot be used to locate other tags such as div.

3. Use js positioning

Copy code
The code is as follows:

<li class="" onclick="javascript:document.getElementById('here').scrollIntoView()"></li>

<<:  Summary of @ usage in CSS (with examples and explanations)

>>:  Detailed explanation of Docker compose orchestration tool

Recommend

A brief discussion on DDL and DML in MySQL

Table of contents Preface 1. DDL 1.1 Database Ope...

Examples of correct use of interface and type methods in TypeScript

Table of contents Preface interface type Appendix...

Analysis of the principle and usage of MySQL continuous aggregation

This article uses examples to illustrate the prin...

Some suggestions on Vue code readability

Table of contents 1. Make good use of components ...

A brief discussion on Mysql specified order sorting query

Recently, I have been working on a large-screen d...

React Routing Link Configuration Details

1. Link's to attribute (1) Place the routing ...

CSS form validation function implementation code

Rendering principle In the form element, there is...

What are the rules for context in JavaScript functions?

Table of contents 1. Rule 1: Object.Method() 1.1 ...

Summary of MySQL view principles and usage examples

This article summarizes the principles and usage ...

What is html file? How to open html file

HTML stands for Hypertext Markup Language. Nowada...

Detailed explanation of JavaScript prototype and examples

Table of contents The relationship between the co...

Implementation of Docker cross-host network (overlay)

1. Docker cross-host communication Docker cross-h...

How to delete a property of an object in JavaScript

1. delete delete is the only real way to remove a...

Detailed example of using the distinct method in MySQL

A distinct Meaning: distinct is used to query the...

Implementation of fuzzy query like%% in MySQL

1, %: represents any 0 or more characters. It can...