Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5: How to specify the width of a file input?

Tags:

html

css

The W3C validator says: "Attribute size not allowed on element input at this point."

<input type="file" name="foo" size="40" />

What is the correct way to specify the width of a file input in HTML5?

like image 796
Brian Bi Avatar asked Nov 12 '12 08:11

Brian Bi


2 Answers

In your css file, specify the width as such:

input[type=file] { width: 300px; border: 2px solid red; }

http://jsfiddle.net/VbTAV/

like image 189
D.Alexander Avatar answered Oct 11 '22 18:10

D.Alexander


In the input field use the style attribute, this allow you to use css.

<input type="file" name="foo" style="width: 40px" />

Or with separate css:

input[name="foo"] {
  width: 40px;
}
like image 44
silppuri Avatar answered Oct 11 '22 16:10

silppuri