-2

I have done it right. use the # sign before the ID so that the navbar link will works. why do "Your file was not found" appear? I will include my HTML codes :

<

!-- Nav Bar -->
      <nav class="navbar navbar-expand-lg navbar-dark ">
        <a class="navbar-brand" href="#">Van-tag</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
          <ul class="navbar-nav ml-auto">
            <li class="nav-item">
              <a href=" nav-link" href="#footer"> Contact</a>
            </li>
            <li class="nav-item">
              <a href="nav-link" href="#pricing"> Pricing</a>
            </li>
            <li class="nav-item">
              <a href="nav-link" href="#cta"> Download</a>
            </li>
          </ul>
        </div>
      </nav>

Here is the link of my full HTML codes. maybe it will helpful. https://code.sololearn.com/WI5eJj8HKGqH/#html

Cleptus
  • 3,446
  • 4
  • 28
  • 34

3 Answers3

1

In order to link to a section of your current page you would need to remove the second href tag

<li class="nav-item">
    <a href="#footer"> Contact</a>
</li>

If you would like to have to multiple links on one anchor tag you could try something like this:

https://stackoverflow.com/a/13965765/9427907

You can read more about anchor tags here:

https://stackoverflow.com/a/21397285/9427907

JJeeff248
  • 13
  • 1
  • 3
1

I do not know how your site is set up, but you have a couple of ways of pointing somewhere in a link:

  1. an absolute normal link to another page:

    <a href="https://www.example.com/myPage.html">Link Text</a>

Here you point at your domain and to the page you want to load.

  1. a relative link to another page:

    <a href="myPage.html">Link Text</a>

Note that in this case the file mySite.html has to be in the same folder as the page you are linking from. Otherwise you have to specify the path as well (e.g. mysubfolder/myPage.html)

  1. an anchor tag:

    <a href="#myAnchor">Link Text</a>

In this case you need an anchor on the very page yo are on so the link knows where to jump to. Any id tag with the right name will work. <div id="myAnchor">Content</div>

  1. a mixture of both

    <a href="myPage.html#myAnchor">Link Text</a>

In which case the file myPage.html has to have the <div id="myAnchor">Content</div> so the link can find the place it is pointing to.

Torf
  • 1,154
  • 11
  • 29
1

if you want to create a link to go another page, you can create a new file html first and linked

<a href="newPage.html">Go new page<a/>

You can create an "internal" link, to go a section o your page, linked with an id attributte, like this:

<h3 id="#internalLink">Section to go</a>

<a href="currentPage.html/#internalLink">Go to section</a>

This link could be useful Html Links Hyperlinks