1

I saw some results via the related questions but didn't actually seem to show what I want. Looking for a way to simply style the button in all major broswers easily.

<input type="file" name="file" id="file" size="29" class="formButton" /> 
<span class="smalltext">(.txt only)</span>

I want the browse button to use the CSS, I have seen some results that put a fake button on top of the real one, is that really the best approach to take?

4 Answers 4

6

Currently, there's no way to consistently style a file input field across browsers. You could use one of the various "tricks" out there (which as you mentioned simply overlay the button), but beware that you might interfere with keyboard access to the field.

Sign up to request clarification or add additional context in comments.

Comments

3

Don't try this!

Even if you get it working, there's still browsers like Safari that use non-standard file selection widgets!

It's best to let the native file widget show through.

Comments

2

The best solution I've found is to either overlay your own as you've mentioned, or use something like Dojo, which effectively does the same thing. As far as I know, you can't style the file input button.

Comments

0

Actually, with JqueryUI you can do it by simply:

Javascript for rollover (not required):

$(".fg-button:not(.ui-state-disabled)")
                .hover(
                    function(){ 
                        $(this).addClass("ui-state-hover"); 
                    },
                    function(){ 
                        $(this).removeClass("ui-state-hover"); 
                    }
                )

Button Code:

<input type="submit" name="something" id="something" value="Submit" class="fg-button ui-state-default ui-corner-all">

Not that due to IE being a Microsoft product, the rounded corners gracefully degrade.

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.