0

How can I avoid that there is a dotted selection rectangle around the text when the user clicks the button, see image below. I already tried to add the css rule user-select: none;, which I saw in another question, but this doesn't seem to work.

rectangle around the text when the user clicks the button

Any suggestions?

EDIT: The issue only appears in Firefox (tested with version 47.0)

.button {
  background-color: #1a1a1a;
  border: none;
  color: #f8f8f8;
  padding: 10px 40px;
  text-align: center;
  display: inline-block;
  font-size: 16px;
  border-radius: 4px;
  user-select: none;
  -webkit-transition-duration: 0.3s;/* Safari */
  transition-duration: 0.3s;
}
.button:hover {
  background-color: #595959;
  /* Green */
  color: white;
}
<button class="button">Button</button>

3
  • 1
    outline: none; but sometimes it's usefull .. Commented Jul 22, 2016 at 12:25
  • There is not selection in your code snipped. To you have the problem in all browsers? Commented Jul 22, 2016 at 12:26
  • I tested it with Opera, Chrome and Firefox. Only in Firefox appears this rectangle. (I used latest versions of all browsers) Commented Jul 22, 2016 at 12:29

3 Answers 3

1

For remove the dotted border in buttons in Firefox:

button::-moz-focus-inner {
  border: 0;
}
Sign up to request clarification or add additional context in comments.

2 Comments

This works. But why do I have to do this in firefox? Other browsers didn't add the dotted border on click
Is for accesibility reasons. From MDN: "Firefox will add, for accessibility purposes, a small dotted border on a focused button. This border is declared through CSS, in the browser stylesheet, but you can override it if necessary to add your own focused style using button::-moz-focus-inner { }" source
0

Simply put this in your CSS :

.yourclass
{
outline:none;
} 

Hope it helps.

Comments

0
button.button:focus {
    outline: 0;
}

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.