Remove border from buttons
Asked Answered
G

14

188

I tried to create buttons and insert my own images instead of the standard button images. However, the gray border from the standard buttons still remains, showing on the outside of my black button images.

Does anyone know how to remove this gray border from the button, so it's just the image itself? Thank you.

Gentlemanatarms answered 16/7, 2012 at 1:23 Comment(3)
Try -webkit-appearance: inherit; or -webkit-appearance:initialBrockbrocken
@Brut: I might be wrong, but that looks browser-specific to me, and I'm pretty sure Jameson wants something that'll work for all modern browsers.Jemadar
In my case I was seeing the box-shadowCatechu
C
289

Add

padding: 0;
border: none;
background: none;

to your buttons.

Demo:

https://jsfiddle.net/Vestride/dkr9b/

Chassis answered 16/7, 2012 at 1:27 Comment(2)
I appreciate.. but i added just like you said to the stylesheet and it didn't work unfortunately. Should I just embed it straight into the html, if that would make a difference?Gentlemanatarms
I added a fiddle plus background: none; to the buttons. Take a peak at the fiddle and see if that works for you.Chassis
I
68

This seems to work for me perfectly.

button:focus { outline: none; }
Intact answered 4/1, 2016 at 5:31 Comment(7)
outline:none; is not recommended for accessibility reasons. If you must remove the focus border, please provide another way for users to see that it has focus. outlinenone.comChassis
Another point of view to the previous comment is that buttons shouldn't necessarily hold focus. If you click it and an action is performed, then the focus should not remain.Anthraquinone
@Anthraquinone If someone is not able to move a mouse pointer to click on a button directly, but instead needs to tab through the form controls to get to the button in question, then they will need some cue to know that they have reached the correct button before activating it.Aleishaalejandra
Note: In general some websites tend to prefer outline visibility for all users to see especially for disabled users. However some websites prefer not to display outlines, it really depends on your website designs and your website audience. For example for an internal admin panel you can do what ever you like as you already know who your website users are and admin panels are private websites not public facing.Intact
Also on highly graphical web pages sometimes items look better without outlines, like those story book websites out there, Im an sure we have all seen them similar to computer game designs.Intact
This link is a fine example of when you might want to remove outlines from your html elements - toivjon.github.io/html5-space-invadersIntact
Here are some more links for you to look at for examples of websites with outlines removed. skylinefilms.tv - thebearandhisscarf.com - longshotfeatures.comIntact
Z
18

I was having the same problem and even though I was styling my button in CSS it would never pick up the border:none but what worked was adding a style directly on the input button like so:

<div style="text-align:center;">
    <input type="submit" class="SubmitButtonClass" style="border:none;" value="" />
</div>
Zirconium answered 4/5, 2013 at 16:8 Comment(1)
you are using the CSS cascade to override the property with a inline style. You should check out some articles on the CSS cascade and CSS specificity.Troup
R
12
input[type="button"] {
border: none;
outline:none;
}
Redshank answered 1/10, 2020 at 0:13 Comment(0)
C
8

You can easily give this style to it:

MyButton {
border: none;
outline: none;
background: none;
}

The border: none; will also do the job for you separately without giving outline (Because: An outline is a line drawn outside the element's border. so when there is no border, outline property doesn't have any meaning on its own).

The background shorthand CSS property sets all background style properties at once, such as color, image, origin and size, or repeat method. so when you set its value to none, then it prevents your button having any color, image and etc....

Changsha answered 12/8, 2021 at 9:3 Comment(0)
D
6

For removing the default 'blue-border' from button on button focus:

In Html:

<button class="new-button">New Button...</button>

And in Css

button.new-button:focus {
    outline: none;
}

Hope it helps :)

Dagenham answered 27/2, 2020 at 15:9 Comment(0)
D
5

Try using: border:0; or border:none;

Deka answered 16/7, 2012 at 1:27 Comment(1)
#button { border: none; } This seems to work just fine.Imprisonment
P
2

You can also try background:none;border:0px to buttons.

also the css selectors are div#yes button{..} and div#no button{..} . hopes it helps

Parthenope answered 16/7, 2012 at 1:31 Comment(2)
Also you can set background of button as images, instead using img tagsParthenope
Or do it in pure css. like background:#555; font-weight:bold: color:#fff; padding:6px 8px;Parthenope
F
2

Add this as css,

button[type=submit]{border:none;}
Flintlock answered 4/6, 2020 at 5:59 Comment(0)
S
2

Just use:

CSS

button {
 border:none; 
 outline:none;
}
Systematist answered 13/6, 2021 at 11:5 Comment(1)
Welcome to StackOverflow. While your code snippet may answer the question, providing additional context regarding why and/or how your code snippet works improves its long-term value. Furthermore it doesn't seem to differ very much from the accepted answer...Unplug
D
1

The usual trick is to make the image itself part of a link instead of a button. Then, you bind the "click" event with a custom handler.

Frameworks like Jquery-UI or Bootstrap does this out of the box. Using one of them may ease a lot the whole application conception by the way.

Decortication answered 16/7, 2012 at 1:30 Comment(0)
C
1

You can target the button in the CSS styling like so:

 div button {
    border: none;
 }
Comestible answered 11/4, 2021 at 0:35 Comment(0)
S
1

HTML code: Then, you can style the link to look like a button.

<button class=”button-solid”>Button without border</button>

CSS code: You might find that your button does not have a border. But when clicked, a border appears on the button. You can remove that border by applying the following CSS code on the button.

.button-solid {
    border: none;
}
button-solid:focus {
    border: none;
    outline: none;
}
Suppletion answered 10/11, 2023 at 9:44 Comment(0)
P
-6
$(".myButtonClass").css(["border:none; background-color:white; padding:0"]);
Portion answered 6/3, 2019 at 19:40 Comment(1)
The person is asking for a css code not a jQuery code.Libbi

© 2022 - 2024 — McMap. All rights reserved.