Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: Submit button looks smaller than text input and textarea

Tags:

html

css

styles

I just noticed this strange rendering of a very simple form.

Here's my markup/CSS: http://jsfiddle.net/a9PLM/

As you can see, text fields and the button share the same styles but their size is quite different.

Why does this happen?

Thanks!

like image 645
willvv Avatar asked Sep 25 '11 02:09

willvv


People also ask

How do you increase the size of a submit button?

Editing the size of a button in HTML is relatively easy. In the simplest form you just have to add a 'style' attribute to the button element containing your desired height and width values in pixels. It goes something like this. Alternatively, you can add a 'class' to button and add your styles in a CSS file.

How do I change the submit button style?

The simplest way to do this is by using the WordPress CSS Editor. To open this, go to Appearance » Customize and select Additional CSS. Once you've opened the Additional CSS section, you can paste in your new CSS, click the Save & Publish button, and you're all set!

Is it valid to have a textarea element inside a button?

You shouldn't try to place a button inside a textarea, that's doesn't make sense semantically and shouldn't be done. You could do what you're currently doing: positioning the button on top of the textarea in the right place.

Can a submit button have a value?

An <input type="submit"> element's value attribute contains a string which is displayed as the button's label. Buttons do not have a true value otherwise.


2 Answers

This is because of the box model being used is different for the <input type="submit"> and the <input type="text">/<textarea>. You can make the box models the same by specifying them with CSS:

box-sizing: border-box;
-moz-box-sizing: border-box;

You can read more about box models here: http://www.quirksmode.org/css/box.html

I edited your jsFiddle to show it working: jsFiddle demo

like image 166
Rusty Fausak Avatar answered Sep 22 '22 00:09

Rusty Fausak


I think this is a browser rendering issue... with buttons being displayed differently than text inputs.

To fix, add this to your css

form input[type="submit"]{
    width:273px;
}

Example: http://jsfiddle.net/jasongennaro/a9PLM/1/

like image 28
Jason Gennaro Avatar answered Sep 23 '22 00:09

Jason Gennaro