In HTML, how do I link to another 'instance' of 'this' document?

99封情书 提交于 2019-12-13 05:36:45

问题


I want to do this for metadata purposes, rather than something that would explicitly displayed . So, for example, say my current document, Page A, is linked to from Page B e.g. a 'related article' in its sidebar. What link relation, or other markup, should I use in Page A to indicate this 'reverse linking' relationship?


回答1:


Take a look at rel attribute.

I would suggest you in order to accomplish what you wrote, use rel="next", respectively rel="prev" inside an anchor tag




回答2:


The rel attribute (which can be used on link, a and area elements) specifies the link relationship type.

In HTML5, you may only use the following rel values:

  • link types defined in the HTML5 specification
  • link types registered in the Microformats wiki on the page http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions

If there is an appropriate link type depends on the specific relationship between your Page A and Page B. You only wrote "related article", but I don’t think that there would be a corresponding link type for such a general relation. I’d guess that all links on a page without a specific link type can be understood as "related".

You shouldn’t use next/prev unless your pages A and B are "part of a sequence".

If you don’t find appropriate link types, you may use RDFa Lite and/or Microdata and look for a suitable vocabulary. For example schema.org’s http://schema.org/WebPage specifies the relatedLink property:

A link related to this web page, for example to other related web pages.

It could look like (using RDFa Lite here):

<!-- on page B -->
<div vocab="http://schema.org/" typeof="WebPage">
  <a href="/article-a" property="relatedLink">Article A</a>
</div>


来源:https://stackoverflow.com/questions/19407088/in-html-how-do-i-link-to-another-instance-of-this-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!