CSS selector for general textboxes
css, css-selectors, html, input
Solution
Do saner solutions exist?
How about a good old fashion class?
`<input class='text' type='text'>`
or overriding the types that are not text
input {
background: red;
}
input[type=radio], input[type=checkbox], input[type=submit] {
background: yellow;
}
Additionally: In my books there is nothing really wrong with your solution.
You just need to add the new html5 input types:
- color
- date
- datetime
- datetime-local
- month
- number
- range
- search
- tel
- time
- url
- week
Problem
Is there a way to select every kind of textbox with a CSS selector to give them all the same width, for instance? By textbox, I simply mean something that the user can type into. My problem is that there are so many of them. It used to be reasonably straightforward; you only had 2 types of textbox with HTML4. These two types were `text` and `password`, so the CSS could be ``` input:not([type]), input[type='text'], input[type='password'] {...} ``` This would cover all of the types. However, with the invention of HTML5, you get many more types, such as `number`, `email`, `url`, `search` and `tel`, that all look and behave the same (except for what you're supposed to type into them), and I'd like to address them all in the same way through CSS. Is it absolutely necessary to write all of this? ``` input:not([type]), input[type='text'], input[type='password'], input[type='number'], input[type='email'], input[type='url'], input[type='search'], input[type='tel'] {...} ``` Is there possibly a much more code efficient way of writing this?