Should I make HTML Anchors with 'name' or 'id'?

前端 未结 14 1238
旧巷少年郎
旧巷少年郎 2020-11-22 00:49

When one wants to refer to some part of a webpage with the \"http://example.com/#foo\" method, should one use

F

14条回答
  •  悲哀的现实
    2020-11-22 01:48

    Just an observation about the markup The markup form in prior versions of HTML provided an anchor point. The markup forms in HTML5 using the id attribute, while mostly equivalent, require an element to identify, almost all of which are normally expected to contain content.

    An empty span or div could be used, for instance, but this usage looks and smells degenerate.

    One thought is to use the wbr element for this purpose. The wbr has an empty content model and simply declares that a line break is possible; this is still a slightly gratuitous use of a markup tag, but much less so than gratuitous document divisions or empty text spans.

提交回复
热议问题