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

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

    The whole "named anchor" concept uses the name attribute, by definition. You should just stick to using the name, but the ID attribute might be handy for some javascript situations.

    As in the comments, you could always use both to hedge your bets.

提交回复
热议问题