Joke Collection Website - Public benefit messages - Several common methods of setting anchor location in html

Several common methods of setting anchor location in html

1. Method 1:

Add an id to the anchor text label and use <: a href="#"> < /a> To locate, when you click the A link, you will jump to the P tag with id a1;

such as:

<; div> < a href="#a1"> < /a> < /div>

< p> Practice <; /p> < p> Practice <; /p> < p> Practice <; /p> < p> Practice <; /p> < p> Practice <; /p>

< p id="a1"> Practice <; /p>

such positioning can be targeted at any tag.

2. Method 2:

Add an anchor point to the text of the A tag, and click the link to jump to the A tag with the name a1;

such as:

<; div> < a href="#a1"> < /a> < /div>

< p> xxx< /p> < p> xxx< /p> < p> xxx< /p> < p> xxx< /p> < p> xxx< /p>

< a name="a1" href=“#”> Practice <; /a>

using the name attribute can only locate the A tag, but it can't locate other tags such as div.

3. Method 3:

Use js, such as

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

Extended materials:

Usage of similar html elements:

1. Hyperlink object

Hyperlink is the abbreviation of hyperlink. According to different users, links in web pages can be divided into text hyperlinks, image hyperlinks, E-mail links, anchor links, multimedia file links, empty links and so on.

a hyperlink is an object that links in the form of specially coded text or graphics. If you click the link, it is equivalent to instructing the browser to move to a certain position in the same webpage, or to open a new webpage, or to open a webpage in a new WWW website.

2. Dynamic static

Hyperlinks can also be divided into dynamic hyperlinks and static hyperlinks. Dynamic hyperlink refers to a hyperlink that can be dynamically changed by changing the HTML code, such as moving the mouse to a text link. Static hyperlinks, as the name implies, are hyperlinks with no dynamic effect.

Baidu encyclopedia-tracing point

Baidu encyclopedia-hyperlink