If is obsolete, what is preferred?

后端 未结 5 2020
北海茫月
北海茫月 2020-12-30 19:24

The HTML code text is very useful for creating links to specific sections of a page (e.g., page.html#some_bookma

5条回答
  •  攒了一身酷
    2020-12-30 20:09

    Using id is not always ideal as they are unique, for example if you have a list of links as menu items and you want to perform some javascript on only certain ones of them when the user hovers over, using id's would be a mess.

    Currently the best way I believe is using a class to identify them as a group.So something like this:

    Menu Item one
    Menu Item two
    Menu Item three
    Menu Item four
    

    But I've just kept on using the name tag, its stupid to deprecate something this minor as it has no performance effect or anything else, just causes problems if browsers decide not to accept the name tag at one moment. It strays us away from using standards as well.

提交回复
热议问题