如何引用HTML页面的特定位置?

bri*_*ant 1 html reference hyperlink

HTML中是否有这样的机制允许我创建一个超链接引用页面中的某个位置,而不是它的开头?

我的意思是,例如,我有一个带有一些文字的页面,在那个文本中有这样的短语:"我喜欢猫".该页面的URL是

http://www.cats.com/bingo.html

因此,当我从另一个页面引用该页面时,我使用类似于此的超链接

[url="http://www.cats.com/bingo.html"]My attitude toward cats[/url]

但这会让我到达我所指的页面的最顶端.如何使超链接打开该页面并向下滚动到文本中的"我喜欢猫"?有可能吗?

Pau*_*ast 5

您可以使用hash-tags和id链接到文本的一部分

例:

<html>
<head>
</head>
<body>
    <p>This is a large piece of text ...</p>
    <p>Another piece of text with <span id="cats">i like cats</span> in it.
</body>
<html>
Run Code Online (Sandbox Code Playgroud)

如果您现在使用链接http://www.cats.com/bingo.html#cats,它将跳转到该部分