Search code examples
htmlbuttonhyperlinkfooter

How can i link button in html to another class/div


I have a 1 page website, how can I link my button if I click it that it goes down to my footer id of my footer is Footersite

My code:

<div class="openbutton">
    <a href="Footersite">
       <p style="color: white; font-size: 17px;">Contact us</p>
    </a>
</div>

But it doesnt go down. How can i fix this?


Solution

  • Even Though you can achieve this with an anchor tag that is not the only way. With button element you can achieve this

    HTML Button

    div {
      margin-top: 800px;
      width: 100px;
      height: 100px;
      background: tomato;
    }
    <button onclick="window.location.href='#abc'">Button</button>
    <div id="abc"></div>

    DEMO

    If you want an anchor element then

    Anchor tag

    div {
      margin-top: 800px;
      width: 100px;
      height: 100px;
      background: tomato;
    }
    <a href="#abc">Link</a>
    <div id="abc"></div>