How to use HTML # anchor in a dynamic url

后端 未结 3 532
后悔当初
后悔当初 2020-12-17 00:35

I want to link to a section of a dynamic page using the # anchor, something like this:

LINK
相关标签:
3条回答
  • 2020-12-17 01:14

    You've only presented half of your code so I can only give a sample of the proper way to do it:

    <body> 
        <a name="top"> </a>
        <a href="#top">
            Go To Top Of Page
        </a>     
    </body>
    
    0 讨论(0)
  • 2020-12-17 01:35

    When using anchor tags, you can target an element by its ID. Browsers will look for the ID before it looks for the name attribute when the link refers to such.

    <a href="#section-name>LINK</a> will go directly to <div id="section-name"> if it exists.

    Here's an example

    Read: HTML Anchors with 'name' or 'id'?

    0 讨论(0)
  • 2020-12-17 01:39

    A typical anchor tag works as follows:

    a href link tag is written like so:

    <a href="anchor_example2.html#a001">Jump to a001</a>
    

    See the #a001 above? That is referencing an id in the html page, it will jump to it if you click this link.

    To provide an example of how this id that we would jump to might look in a page look below.

    <li id="a001">text here</li>
    

    reference

    0 讨论(0)
提交回复
热议问题