legacy-knowledge-base
公開されました Jul. 2, 2025

HTMLアンカーを使う

written-by

Justin Choi

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • HTMLアンカーを使用した目次を持つWebページを構築する際、トップリンクをクリックしても、ページ内の正しい場所にリダイレクトされないことがある。

環境

  • DXP 7.0、DXP 7.1

解像度

最新のHTML規約では、 href="#"id= のペアリングを使用しています。 Web要素が一致していること、つまり各hrefに対応するidがあることを確認します。 次に、Web要素がユニークであることを確認します。同じ名前のアンカーを2つ持つことはできません。

以下に例を示します。

<h3><a href="#chapter1">第1章</a><h3> は目次の部分に入りながら

<h3><a id="chapter1">第1章</a><h3> は本文に入ります。

また、 href="#"id=" は、余分な(<a> </a>)を落とすことで、 <h3> の中に安全にネストできるケースもあることに注意してください。

追加情報

did-this-article-resolve-your-issue

legacy-knowledge-base