pf » Styling input based on their type with CSS
Styling input based on their type with CSS
A few weeks ago I posted how I style forms with CSS. Here's another trick that could be used with that technique.
Suppose your creating a form with a couple text fields and a submit button. Now you want to set the width of the text fields, but you want your submit button to be set to the default size. If you did something like this:
input { width: 200px; }
All input tags would be 200px; we only want input tags with type="text" to be 200px; you can use attribute selectors:
input[type="text"] { width: 200px; }
Attribute selectors are super handy but they don't work in IE6! You may still find them useful, just make sure you test on IE to make sure things still look ok.
Related Entries
- Web Standards Browser Test - April 14, 2005
That is why CSS has this thing called classes. Designate a class for the text inputs and one for the button inputs.
http://dean.edwards.name/IE7/
This library also fixes other IE6 issues, such as:
* Pure CSS Menus * Complexspiral * Box-Model * Fixed Positioning * Dynamic Pseudo Classes * Rounded Corners * XML * PNG Transparency
*which doesn't work for 89%-90% for your potential user-base.
Roll on IE7 and automatic update, I say!
<style type="text/css"> INPUT.text { /* text style */ }
INPUT.file { /* file style */ }
INPUT.button { /* button style */ } </style>
I'm under the impression it works under IE6, but not 100% sure as I don't have access to IE6 any more since upgrading.
<style type="text/css"> INPUT.text { /* text style */ }
INPUT.file { /* file style */ }
INPUT.button { /* button style */ } </style>
- CFSCRIPT Cheatsheet
- 3 New Image Effects for ColdFusion 8
- Googlebot to Submit Web Forms
- ColdFusion 8 Update 1 Fixes some Image Processing Quirks
- 10 Most Useful Image Functions in ColdFusion 8
- Speaking at NYC CFUG This Week
- Adobe AIR Tutorial for HTML / JavaScript Developers
- INFORMATION_SCHEMA Support in MySQL, PostgreSQL
RSS
add to del.icio.us
Pete Freitag is a software engineer, and web developer located in










