|
|
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!
More Useful HTML, JavaScript and Web Site Programming Articles:
✔ How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔ Can I embed a Facebook search box on my blog site?I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔ Can I use CSS for drop shadows on my blog?I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔ How can I embed interactive photo panoramas on my site/blog?I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔ How can I create a Twitter search URL shortcut?I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help
right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
Categorized:
HTML, JavaScript and Web Site Programming
(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? Reader Comments To Date: 12Dave Taylor said, on January 29, 2007 10:15 AM:
Yowza. What a gaffe. Fixed! :-) Nikolaus Tan said, on April 28, 2008 1:25 AM:
Hmm Dave..its a nice topics, but how can i use the .tiff file instead of ordinary image files.Thank you very much ^^ Justin said, on August 13, 2008 4:21 AM:
Hi Dave, Can i get a image as textfield 2? that plain white box is so boring :D Koja said, on December 2, 2010 2:42 AM:
10x man great tutorial! Svetlana said, on August 20, 2011 8:13 AM:
Thank you, this works! bvglooks said, on August 30, 2011 9:21 AM:
Hi.. 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, Dave Taylor said, on September 2, 2011 8:27 AM:
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. Danielle Wu said, on May 20, 2012 10:38 AM:
Hi, do you know how I could change the appearance of all buttons on my site? My platform is blogger and a lot of the buttons are already laid out for me: http://daniellewu.com I simply want to change the appearance of the "submit" and "search" buttons. Thanks!:) jim said, on October 16, 2012 7:16 AM:
Hi Dave Found a bug in your page code. "Search on Yahoo" example had the regular-looking submit button (but with the revise "go!" text) on Chrome-de-jour so I tried it on IE8 with same result and then FF-de-jour and still same old submit button appearance (text was correct). So I FireBugged your page code and found this: <p> Removing the first BR element work fixed the problem (button now renders as desired)... but removing both keeps it real clean: <p><style rel="stylesheet" type="text/css"> Finally, -- at least on the browser I can edit with FireBug (FF 16) -- one can eliminate the <P> tags and just have the STYLE element in-line for the cleanest page code: <style rel="stylesheet" type="text/css">#mysubmit { background-color: #cfc; font-size: 60%; padding: 20px; font-weight: bold; }</style> Hope all goes well. I dropped by looking for ways to add a Google Search box to a friend's page in such a way that it would search only her site. Found your recommendations and now am off to do battle with the HTML editor! :-) Dave Taylor said, on October 16, 2012 7:54 AM:
Nice job, Jim. Haven't looked at this code for a while... :-) ener said, on May 16, 2013 5:39 PM:
hello , thanks for the script sir, if you are vacant and could give a hand can someone help me make facebook apps ? heheheh please contact me
I do have a comment, now that you mention it!Check This Out Too... |
Recent Entries
Look for Answers
Recommended
All Our Categories
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and Blogging Building Web Site Traffic Business and Management Computer and Internet Basics d) None of the Above Facebook Help Google Gmail Help Google Plus Help HTML, JavaScript and Web Site Programming Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Kindle Fire Help Mac OS X Help Pay Per Click (PPC) Advertising Pinterest Help 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 Find Me on Google+ ADT on G+ |
Thx very much, just one little type error: you got all the > at the end of a tag mixed up for a <