Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gorgeous web buttons with proper behavior, can it be done?

For my application, I wanted to style the submit buttons nicely. With normal CSS, I managed to get it to look good in Firefox, and horrible in IE. Then I saw this blog entry:

http://www.sohtanaka.com/web-design/liquid-color-adjustable-css-buttons/

Using that technique you get gorgeous buttons, in pretty much all browsers. However, there are also a few accessibility issues:

  • Since it uses links instead of real HTML input or button elements, clicking the button does not submit the form. This is easily resolved using Javascript, but it would be ideal if the submit button works without Javascript enabled.
  • Another issue is that hitting [ENTER] does not submit the form. A dirty hack is to include an invisible input element of type "submit" or "image".

Basically what I want is perhaps the impossible: The quality of the styling as seen in the blog entry, yet implemented using normal elements so that I get normal behavior.

Do I really have to chose between dirty hacks or poor styling?

Every button styling tutorial that I have seen so far has sub optimal results in IE :(

like image 375
Fer Avatar asked Jan 15 '10 13:01

Fer


People also ask

What is website button?

Definition and Usage. The <button> tag defines a clickable button. Inside a <button> element you can put text (and tags like <i> , <b> , <strong> , <br> , <img> , etc.). That is not possible with a button created with the <input> element!

Can you create buttons in CSS?

To create text buttons first, we create simple buttons in HTML using a button tag. After creating the button we apply CSS and change its properties to make it look like a text button. To make it look like a text button we remove its default border and background.

How do you make a button work in HTML?

The plain HTML way is to put it in a <form> wherein you specify the desired target URL in the action attribute. If necessary, set CSS display: inline; on the form to keep it in the flow with the surrounding text. Instead of <input type="submit"> in above example, you can also use <button type="submit"> .


1 Answers

Do I really have to chose between dirty hacks or poor styling?

No, you could use Javascript like the rest of us. Load in your standard form (complete with submit-button), and then use neatly-written Javascript to dynamically "fix" some of the ugly elements. I'd suggest evaluating the jQuery framework for this type of thing if you wish to use clean code, and get cross-browser support.

like image 66
Sampson Avatar answered Oct 16 '22 16:10

Sampson