如何通过url链接加载页面并滚动到html元素?

如何通过url链接加载页面并滚动到html元素?,html,Html,我在我的网站首页上有以下链接: 也试过了 然后在目标页面中,我有以下内容: <h2 style="text-align: center;" id="formulario"><a href="#formulario"></a>Sol·licita el teu servei aquí</h2> Sol·licita el teu servei aqí 问题是页面加载不在正确的位置,无法首先显示h2元素 如何解决此问题?在HTML 4之前,目标必须

我在我的网站首页上有以下链接:

也试过了

然后在目标页面中,我有以下内容:

<h2 style="text-align: center;" id="formulario"><a href="#formulario"></a>Sol·licita el teu servei aquí</h2>
Sol·licita el teu servei aqí
问题是页面加载不在正确的位置,无法首先显示h2元素


如何解决此问题?

在HTML 4之前,目标必须是

<a name="formulario">Sol·licita el teu servei aquí</a>

此[name]属性是定义页面中可能目标位置的锚所必需的。在HTML4.01中,id和name可以同时用于
元素,只要它们具有相同的值


请修改你的问题。。。由于不清楚。。
<h2 id="formulario">Sol·licita el teu servei aquí</h2>