2013-07-30

CSS selector for all the textboxes

Usual way of applying styles for all the textboxes is like below

input[type="text"] {
    /*CSS here*/
}

Problem with the above is, it will not include the textboxes which get renders when you simply put a <input> tag. Note that when you do not specify the type attribute in input elements, it will render as the default input element, textbox. The above CSS selector won't work in such cases. In such cases, you can use the below

input:not([type]), input[type="text"]
{
  /*CSS here*/
}

It will select all the input control without a type attribute as well as which are marked as type=”text”

No comments: