Proper URL forming with Query String and Anchor Hashtag

前端 未结 5 1527
粉色の甜心
粉色の甜心 2020-12-04 11:27

When both a query string and anchor tag (hash tag) are visible in a URL, what is the proper order for them to appear?

http://www.whatever.com?var=val#anchor

5条回答
  •  盖世英雄少女心
    2020-12-04 12:27

    ? should come before the # as noted in RFC 3986:

    relative-ref = relative-part [ "?" query ] [ "#" fragment ]
    

    Taken from an answer over at superuser (https://superuser.com/questions/498617/does-an-anchor-tag-come-before-the-query-string-or-after):

提交回复
热议问题