XML technologies / CSS / CSS Cookbook / Forms / Submit buttons displayed as plain HTML text

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Problem

A submit button should look like ordinary HTML text.

Solution

Various CSS formatting properties produce the desired HTML text appearance.

First give the element input an attribute class with a suitable value:

<input type="submit" name="submit" value="send &raquo;" class="submit" />

Then assign the class the CSS properties needed to remove the button’s border and background color (see the next figure):

.submit {
 border: none;
 background-color: #fff;
 padding: 0;
 margin: 0;
 width: 5em;
}

A submit button displayed as HTML text

Figure: A submit button displayed as HTML text.

The pseudo-class :hover also creates a rollover effect (see the next figure):

.submit:hover {
 text-decoration: underline;
}

The text-style button is underlined when hovered

Figure: The text-style button is underlined when hovered.

Discussion

Matching submit buttons to surrounding HTML text suits designers who feel generic buttons do not fit their design but do not want to use an image instead.

Submit buttons can sometimes reduce the user experience because some users hesitate to send data through a form with such a button. Displaying it as a text link can remove that hesitation, since clicking a link presents a lower barrier.

This recipe works only in browsers allowing submit button appearance to change, including Mozilla, Firefox, Netscape Navigator 7+ and Opera. Safari is excluded because it always uses native Macintosh buttons.

See also

The recipe Using plain HTML text links as submit buttons for the reverse approach.

  

 

 

 

back to top