search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Table of Contents
to point to the id when creating a link. For example, the navigation menu can link to different chapters of the page, and after clicking, the page scrolls to the corresponding position. It is recommended that id use lowercase letters and hyphens to avoid spaces and special characters, and the name attribute is deprecated, id should always be used. This anchor link can be used on the same page or external page, in the format #id, simple and compatible, ending with a complete sentence.

How to link to a specific part of a page in HTML5?

To link to a specific part of a page in HTML5, you use fragment identifiers (also known as anchor links). This involves two parts: creating a target location on the page and linking to it.

How to link to a specific part of a page in HTML5?

1. Set the target with an id attribute

Give the section you want to link to a unique id . Any HTML element can have an id , and that makes it a valid destination.

%%PRE_BLOCK_0%%

You can also use it on a div or any block-level element:

How to link to a specific part of a page in HTML5?%%PRE_BLOCK_1%%

2. Create a link using the href with a hash ( # )

To link to that section, use an tag with href="#id" :

%%PRE_BLOCK_2%%

When clicked, this link will scroll the page to the element with id="section1" .

How to link to a specific part of a page in HTML5?

Example in full:

%%PRE_BLOCK_3%%

Notes and tips:

  • Use lowercase, hyphenated id values for consistency and compatibility (eg, id="key-points" ).
  • Avoid spaces or special characters in id attributes.
  • The name attribute (used in older HTML) is obsolete for this purpose — always use id in HTML5.
  • These links work within the same page or from external pages (eg, https://example.com/page.html#section1 ).

Basically, just assign an id , then link to it with #id . It's simple and widely supported.

">; 2. Use to point to the id when creating a link. For example, the navigation menu can link to different chapters of the page, and after clicking, the page scrolls to the corresponding position. It is recommended that id use lowercase letters and hyphens to avoid spaces and special characters, and the name attribute is deprecated, id should always be used. This anchor link can be used on the same page or external page, in the format #id, simple and compatible, ending with a complete sentence.

How to link to a specific part of a page in HTML5?

To link to a specific part of a page in HTML5, you use fragment identifiers (also known as anchor links). This involves two parts: creating a target location on the page and linking to it.

How to link to a specific part of a page in HTML5?

1. Set the target with an id attribute

Give the section you want to link to a unique id . Any HTML element can have an id , and that makes it a valid destination.

%%PRE_BLOCK_0%%

You can also use it on a div or any block-level element:

How to link to a specific part of a page in HTML5?%%PRE_BLOCK_1%%

2. Create a link using the href with a hash ( # )

To link to that section, use an tag with href="#id" :

%%PRE_BLOCK_2%%

When clicked, this link will scroll the page to the element with id="section1" .

How to link to a specific part of a page in HTML5?

Example in full:

%%PRE_BLOCK_3%%

Notes and tips:

  • Use lowercase, hyphenated id values for consistency and compatibility (eg, id="key-points" ).
  • Avoid spaces or special characters in id attributes.
  • The name attribute (used in older HTML) is obsolete for this purpose — always use id in HTML5.
  • These links work within the same page or from external pages (eg, https://example.com/page.html#section1 ).

Basically, just assign an id , then link to it with #id . It's simple and widely supported.

Home Web Front-end H5 Tutorial How to link to a specific part of a page in HTML5?

How to link to a specific part of a page in HTML5?

Aug 15, 2025 am 12:48 AM

To link to a specific part of the page, you need to set the target position using the id attribute and link to the id with a # number. 1. Add a unique id to the element you want to link, such as

; 2. Use to point to the id when creating a link. For example, the navigation menu can link to different chapters of the page, and after clicking, the page scrolls to the corresponding position. It is recommended that id use lowercase letters and hyphens to avoid spaces and special characters, and the name attribute is deprecated, id should always be used. This anchor link can be used on the same page or external page, in the format #id, simple and compatible, ending with a complete sentence.

How to link to a specific part of a page in HTML5?

To link to a specific part of a page in HTML5, you use fragment identifiers (also known as anchor links). This involves two parts: creating a target location on the page and linking to it.

How to link to a specific part of a page in HTML5?

1. Set the target with an id attribute

Give the section you want to link to a unique id . Any HTML element can have an id , and that makes it a valid destination.

 <h2 id="section1">Section 1</h2>
<p>This is the first section.</p>

You can also use it on a div or any block-level element:

How to link to a specific part of a page in HTML5?
 <div id="top">Page top</div>

2. Create a link using the href with a hash ( # )

To link to that section, use an <a> tag with href="#id" :

 <a href="#section1">Go to Section 1</a>

When clicked, this link will scroll the page to the element with id="section1" .

How to link to a specific part of a page in HTML5?

Example in full:

 <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Fragment Link Example</title>
</head>
<body>
  <nav>
    <a href="#introduction">Introduction</a> |
    <a href="#features">Features</a> |
    <a href="#conclusion">Conclusion</a>
  </nav>

  <h2 id="introduction">Introduction</h2>
  <p>Welcome to our guide...</p>

  <h2 id="features">Features</h2>
  <p>Here are the main features...</p>

  <h2 id="conclusion">Conclusion</h2>
  <p>Thanks for reading!</p>
</body>
</html>

Notes and tips:

  • Use lowercase, hyphenated id values for consistency and compatibility (eg, id="key-points" ).
  • Avoid spaces or special characters in id attributes.
  • The name attribute (used in older HTML) is obsolete for this purpose — always use id in HTML5.
  • These links work within the same page or from external pages (eg, https://example.com/page.html#section1 ).

Basically, just assign an id , then link to it with #id . It's simple and widely supported.

The above is the detailed content of How to link to a specific part of a page in HTML5?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Popular tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to center an image vertically in HTML5? (Layout techniques) How to center an image vertically in HTML5? (Layout techniques) Mar 07, 2026 am 02:05 AM

Flexbox is the most stable for centered images. The key is to set display:flex and align-items:center in the parent container and specify the height; using place-items:center for Grid is more concise; absolute positioning requires top:50% with transform:translateY(-50%); vertical-align is invalid for block-level centering.

How to use SVG graphics directly in HTML5? (Inline SVG) How to use SVG graphics directly in HTML5? (Inline SVG) Mar 07, 2026 am 01:40 AM

SVG tags can be written directly into HTML without any external reference. The core of InlineSVG is to use it as an ordinary HTML element. The browser supports it natively. It does not require additional loading, does not trigger HTTP requests, and can be directly controlled by CSS and JS. A common mistake is to insert it as an image - this way you lose the advantage of inlining, the style cannot penetrate, and JS cannot get inside. Directly copy the SVG source code (exported from Figma, or handwritten), and paste it into an HTML file or any container. Make sure the beginning is, the end is, and there is no DOCTYPE in the middle. Delete useless attributes such as xmlns="http://www.

Related articles