我想在页面中添加一个HTML锚标记,但不会影响布局或格式。当使用<a>
、<p>
或<div>
等时,引入了一些垂直空白。
有没有一种方法可以包括一个锚点,这样它就不会影响页面的视觉显示?
假设我不想在已经存在的段落或其他元素中包含此锚点,并且我只想在不更改页面显示的情况下,在页面中的任何位置随意引入该锚点。
更新1
这是一个简单的例子。在下面插入anchor1
引入了垂直空间。有没有一种方法可以在不影响视觉布局的情况下随意插入锚?锚点将用作跳转到页面上特定位置的链接。
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<p id="anchor1"></p>
<p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p>
如果不能将ID添加到现有元素,请使用实际的锚点:
HTML
<a>
元素(或HTML锚定元素)定义超链接、超链接的命名目标目的地或两者。
HTML4:
<a name="anchor1"></a>
HTML5:
<a id="anchor1"></a>