I'm trying to remove the margin between the search bar and the "Go!" button at the top of this page: http://beta.linksku.com/
I've tried removing all styles and adding margin:0;padding:0;border:none;
, but there is still a margin between the two elements. I cannot replicate this problem on JSFiddle, but it occurs in all browsers on my website.
Approach 1: We can remove space between any two tags by simply using margin-bottom property. The margin-bottom property sets the bottom margin of an element.
If you have no margin or padding applied and you still have this space, you could either use display: flex on the parent or display: block/inline-block on the label to get rid of these. Both label and input are display: inline , per default, so margin and padding bottom or top should not affect them.
Set margin-top property to set space between two text boxes.
The space you're seeing is the default padding applied to inline elements. Simplest hack? Set font-size: 0
on the form
, then reset the actual font-size on the input and button.
Magic.
form {
font-size: 0;
}
form input {
font-size: 12px;
Why does this occur? The browser interprets the whitespace between the input
s as a textual space, and renders accordingly. You can also smush all your elements together on one line, but that's ugly code soup.
This is how elements function as inline-block
.
Normally when you use inline-block
elements, you often use them inside a paragraph, so the space between the letters must be consistent. inline-block
elements apply to this rule too.
If you want to remove the space completely, you can float the elements.
float: left;
You can also remove the whitespace from your template document. Like so:
<input type="text" name="s" tabindex="2" /><input type="submit" value="Go!" class="btn" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With