Kaitlyn Wright
Kaitlyn Wright

Reputation: 11

How to remove grey "border" on HTML buttons

I am seeing a border around my buttons on an HTML webpage. I am trying to make one button blue and one green and they are placed in a table. Code below:

<table align="center">
  <tr style=" font-family: verdana; font-size: 24px;">
    <th> Select your Region </th>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
    <td align="center">
      <button>
            <a id="cust" type="button" 
            style=
            "background-color: #00824A;
              border: none;
              color: white;
              padding: 16px 55px;
              text-align: center;
              text-decoration: none;
              display: inline-block;
              font-size: 16px;
              margin: 4px 2px;
              transition-duration: 0.4s;
              cursor: pointer;
              font-weight: bold;
              font-family: verdana"
            href="URL">
            US
            </a>
            </button>
    </td>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
    <td align="center">
      <button>
            <a id="cust" type="button" 
            style=
            "background-color: #0061D5;
              border: none;
              color: white;
              padding: 16px 55px;
              text-align: center;
              text-decoration: none;
              display: inline-block;
              font-size: 16px;
              margin: 4px 2px;
              transition-duration: 0.4s;
              cursor: pointer;
              font-weight: bold;
              font-family: verdana" 
            href="URL">
            EU
            </a>
            </button>
    </td>
  </tr>
</table>

This is how they are showing up on the webpage:

enter image description here

I was expecting the whole button to be that color without the grey around the sides of it. I removed the "border" with border: none in the styles. Instead, it shows a rectangle of the color within the larger grey button.

Upvotes: 1

Views: 381

Answers (1)

Andi
Andi

Reputation: 2992

The border is the button element itself, not the link <a> you've got inside of it. You need to style the button and remove the default border with <button style="border: none;">

Relevant reading: https://css-tricks.com/overriding-default-button-styles/

<table align="center">
  <tr style=" font-family: verdana; font-size: 24px;">
    <th> Select your Region </th>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
    <td align="center">
      <button style="border: none;">
            <a id="cust" type="button" 
            style=
            "background-color: #00824A;
              border: none;
              color: white;
              padding: 16px 55px;
              text-align: center;
              text-decoration: none;
              display: inline-block;
              font-size: 16px;
              margin: 4px 2px;
              transition-duration: 0.4s;
              cursor: pointer;
              font-weight: bold;
              font-family: verdana"
            href="URL">
            US
            </a>
            </button>
    </td>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
  </tr>
  <tr>
    <td align="center">
      <button style="border:none;">
            <a id="cust" type="button" 
            style=
            "background-color: #0061D5;
              border: none;
              color: white;
              padding: 16px 55px;
              text-align: center;
              text-decoration: none;
              display: inline-block;
              font-size: 16px;
              margin: 4px 2px;
              transition-duration: 0.4s;
              cursor: pointer;
              font-weight: bold;
              font-family: verdana" 
            href="URL">
            EU
            </a>
            </button>
    </td>
  </tr>
</table>

Upvotes: 2

Related Questions