Industry guru Dave Taylor answers free tech support questions about a wide variety of business and technical topics, including blogging, Google AdSense, MySpace, Sony PSP, Apple iPod, Mp3 players, management, Linux, SEO, Mac OS X, Facebook, Twitter, LinkedIn and Microsoft Windows.

How do I change the appearance of a SUBMIT button?

Dave, how can you change the attributes of the Submit button (font, color, color of the button, etc.)? When I get the answer, I promise to buy you that chai.


Dave's Answer:

Well, thanks for buying me a chai first off! :-)

There are two different ways that you can tweak the appearance of a submit button in an HTML form: you can use Cascading Style Sheet attributes, or you can simply replace it with a graphic.

The latter is easier to explain, so check this out:

<form method="get" action="http://search.yahoo.com/search">
<b>Search on Yahoo: </b>
<input type="text" name="p" />
<input type="image" name="submit" src="submit.png" border="0" />
</form>

Here's how this mini-form -- a Yahoo search box for your own Web page, actually -- looks when I add my rather crazy looking submit button:


Search on Yahoo:

Try it, the form really works.

That's one way you can get the submit button to look as you desire: just create it in a button editor or graphics editor and you're set.

The other way to work with the submit button, however, a way that's far more common, is to make some tweaks in the CSS stylesheet for the page itself. This can be done within the submit tag itself, using the style="" attribute, but I prefer to drop it into its own style block at the top of the page.

That looks like this:

<style type="text/css" rel="stylesheet">
#mysubmit { background-color: #cfc; font-size: 60%;
    padding: 20px; font-weight: bold; }
</style>

<form method="get" action="http://search.yahoo.com/search">
<b>Search on Yahoo: </b>
<input type="text" name="p" />
<input type="submit" id="mysubmit" value="go!" />
</form>

I'm using the "id" attribute to target a specific element of the page with the CSS modifications ("mysubmit") and it's very important ot note that some browsers just cannot render these stylized buttons properly, processing some attribute changes, but ignoring others.

In this example, I'm changing the size of the text in the submit button (making it smaller and bold), changing the background color of the button from the usual grey to a light green, and making the button itself larger by adding more padding than usual. Here's the result:

Search on Yahoo:

Note that your browser might well not show anything fancy, so I'll also show you how it renders in the CSS-friendly Firefox browser:

Firefox displaying CSS modified SUBMIT button

Hope that helps you start traveling down the road to custom submit buttons!



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized: HTML and CSS   (Article 6525)
Tagged: , ,
Previous: What is Cinco de Mayo?
Next: How do I add web links to my LinkedIn Profile?

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

Thx very much, just one little type error: you got all the > at the end of a tag mixed up for a <

Posted by: Harm at January 28, 2007 4:08 AM

Yowza. What a gaffe. Fixed! :-)

Posted by: Dave Taylor at January 29, 2007 10:15 AM

Hmm Dave..its a nice topics, but how can i use the .tiff file instead of ordinary image files.Thank you very much ^^

Posted by: Nikolaus Tan at April 28, 2008 1:25 AM

I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!









Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Uniblue: Free Virus Scan

Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Join the List!
Join my author info mailing list, where you'll learn about my upcoming books, speaking gigs, and more!


Book Links
© 2002 - 2008 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]