htmlcsssvgbuttongoogle-material-icons

HTML CSS: Make Google Icon into Button without Rectangle around it


How do I make a Google Icon into a Button? However, do not want a rectangular box around the button. The icon pixels will be a button itself.

.testdelete {
     font-family: Material Icons;
}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

<span class="testdelete">
 delete
</span>
  

Link below places a rectangle around button, something don't want.

https://www.w3schools.com/howto/howto_css_icon_buttons.asp


Solution

  • Why not use an tag to simulate a button?

    $( ".testdelete" ).click(function() {
      $("p").hide();
    });
    .testdelete {
         font-family: Material Icons;
    }
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    
    
    
    <a class="testdelete">
     delete
    </a>
    
    <p class="hi">To be deleted</p>

    You can also use <button>tweet</button> and handle the background and border removal with css:

    .button {
    background: none;
    border: none;
    color: black;
    }