skip to Main Content

I need to make all this divs into buttons, here is my full code:

    <div class="mc-button full">
      <div type="button" class="title">1.19.3</div>
    </div>

I tried add this

    <div class="mc-button full">
      <div type="button" href="about1-19-3.html" class="title">1.19.3</div>
    </div>` 

But it doesn’t work.

3

Answers


  1. <div class="mc-button full">
      <div type="button" href="about1-19-3.html" class="title">1.19.3</div>
    </div>`
    

    This should be converted into something like this…

    <div class="mc-button full">
      <button type="submit" @onclick="location.href("/about1-19-3.html")" class="title">1.19.3</div>
    </div>`
    

    Or something like this…

    <div class="mc-button full">
      <a href="/about1-19-3.html" class="title">1.19.3</a>
    </div>`
    
    Login or Signup to reply.
  2. You mix a lot of different things here.

    A button is a trigger to fire a script.

    <button>Text of a button</button>
    

    You use this in combination with either onclick attribute or directly in JS with an addEventListener to fire a script.

    A link connects another resource to your document.

    <head>
      <link rel="" href="">
    </head>
    

    That connects another resource such as CSS, Favicons to your document.

    An anchor directs to another resource.

    <a href="">Anchor Text</a>
    

    that if clickd, will redirect you to another resource by either changing the current tab, opening a new tab or by downloading another resource.

    A div is just an unspecific block-level container. If you want to use href to re-direct do another element you either want to use an anchor or you need JS to add an eventListener to redirect. Markup valid-wise you should use JS:

    <div class="mc-button full">
      <div onclick="location.href = 'about1-19-3.html';" class="title">1.19.3</div>
    </div>

    However, with only 1.19.3 as content it mostlikely should be an anchor:

    <div class="mc-button full">
      <a href="about1-19-3.html" class="title">1.19.3</div>
    </div>
    Login or Signup to reply.
  3. why for any reason would you turn a div into a button?
    suprise, you also can’t add a type attribute to a div.
    But if you insist, Here is your answer:

    <div class="button">Click Me!</div>
    
     .button {
        width: 130px;
        background-color: rgb(44, 43, 43);
        text-align: center;
        color: white;
        font-family: sans-serif, serif;
        font-weight: 900;
        padding: 10px;
        border-radius: 2px;
        box-sizing: border-box;
    }
    
    .button:active {
        background-color: #7c7878;
        border: none;
    }
        
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search