Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I remove this weird outline around my element?

I am getting a weird outline like something around my button for this styles. Why is it happening.
Below is the code:

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Button</title>
        <style>
          button {
            padding: 1em;
            background: transparent;
            border: none;
          }
          button:focus {
            border-radius: 6px;
            outline: none;
            box-shadow: 0 0 0 2px white, 0 0 0 4px blue;
          }
        </style>
      </head>
      <body>
        <button>Button</button>
      </body>
    </html>

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If for some specific design reason, @Yuvaraj M’s answer doesn’t cover your case, consider using inset shadow for the white part.

button {
  padding: 1em;
  background: transparent;
  border: none;
}

button:focus {
  border-radius: 6px;
  outline: none;
  box-shadow: inset 0 0 0 2px white, 0 0 0 2px blue;
}
<button>Button</button>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading