我们中的许多人在检查某些网站时可能已经观察到 URL 中的井号 (#)。它不是一个简单的常规字符,而是具有特殊函数。所以首先,它被称为命名锚点或有时称为片段。命名锚点或片段用于链接到同一网页的部分。我们通常将一个页面链接到另一个页面,但是如果我们必须链接到同一网页上的某个标题怎么办?然后,命名锚(#)开始发挥作用。
语法:它只会指向同一页面的顶部,因为该锚标记没有给出任何链接。
示例:例如,您有一个很长的网页,其中有几个标题可以直接导航到这些标题中,这将很有帮助。然后为了将用户指向带有链接的特定标题,链接必须包含。因此,基本上为了将用户指向某个特定的标题,我们在锚标记中使用带有该标题名称的井号。当使用空而没有其他配音标题时,相同的链接指向同一页面的顶部。
注意:空白 # 符号不会带你去任何地方,因为它没有链接到任何 id 属性。
- 程序:
link has a pound “#” sign GeeksforGeeks
A Computer Science Portal for GeeksLearn
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and many more.
Contribute
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and many more.
Explore
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and many more.
- 输出: