1

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.

1
  • 3
    A word of advice - you should really be using either a <button> element or <a> element, but not one inside of the other. That will cause some accessibility issues because of their differing purposes. A <button> is meant to be used to interact with the page (like submitting a form or opening a dialog), and an <a> element is meant to be a link. Commented Jan 12, 2023 at 23:58

1 Answer 1

2

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>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.