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

前端 未结 14 1435
旧巷少年郎
旧巷少年郎 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:33

    The second sample assigns a unique ID to the element in question. This element can then be manipulated or accessed using DHTML.

    The first one, on the other hand, sets a named location within the document, akin to a bookmark. Attached to an "anchor", it makes perfect sense.

提交回复
热议问题