|
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. 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: 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"> 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: 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: ![]() Hope that helps you start traveling down the road to custom submit buttons!
Categorized:
HTML and CSS
(Article 6525,
Written by Dave Taylor)
Tagged: css, html, yahoo Previous: What is Cinco de Mayo? Next: How do I add web links to my LinkedIn Profile? Subscribe!
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 AMYowza. What a gaffe. Fixed! :-) Posted by: Dave Taylor at January 29, 2007 10:15 AMHmm 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 AMHi Dave, Can i get a image as textfield 2? that plain white box is so boring :D Posted by: Justin at August 13, 2008 4:21 AM10x man great tutorial! Posted by: Koja at December 2, 2010 2:42 AMThank you, this works! Posted by: Svetlana at August 20, 2011 8:13 AMHi.. I wanted to know what exact file has the code you modified? I checked htmlviewer.css and SP_Full.css but could not find similar code in it to change. Thanks, bvglooks, not sure what you're asking. The code we've modified is embedded in the HTML page that includes the submit button. I don't know what your .css files are associated with (a wordpress installation?) but what you seek is going to be on an .html page or a template that produces an html page. Posted by: Dave Taylor at September 2, 2011 8:27 AMI have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |