Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select <input> that has no "type" with CSS

Tags:

I here have 3 <input>s in my HTML:

Name: <input><br> Age: <input type="number"><br> Site: <input type="url"> 

And I can select the bottom two with these CSS:

input[type="number"]{     color: gray; } input[type="url"]{     color: blue; } 

But I don't know how to select the first one that has no type.
I tried:

input{     color: red; } 

But it will change the other two as well.

input[type=""]{     color: red; } 

This is still not working.
Any idea?

like image 864
Derek 朕會功夫 Avatar asked Nov 22 '11 06:11

Derek 朕會功夫


People also ask

What is the correct selector for targeting all text inputs that are not disabled CSS?

The :enabled pseudo-class in CSS selects focusable elements that are not disabled, and therefore enabled.


2 Answers

The selector input[type=""] will look for an input that has the attribute type which is set to empty. Try using this:

input:not([type]) { } 

See the jsFiddle.

like image 68
animuson Avatar answered Sep 22 '22 07:09

animuson


Another approach could be to use CSS Specificity, and apply a general style to all input elements, then apply more specific styles to inputs with type attribute. :)

like image 22
Saeed Neamati Avatar answered Sep 22 '22 07:09

Saeed Neamati