colinramsay.co.uk

CSS Selectors in IE7

15 Oct 2008

I'm quite partial to doing something like this in my CSS:

input { border: 1px solid #ccc; }

That'll give every textfield a single pixel border. The trouble with that is we'll also get one on every radio button and checkbox too, which looks rubbish. Even though IE7 has been out for ages, I'd never really bothered to absorb what CSS features it provides. Lowest common denominator is still important in web applications, with IE6 having a statistically significant portion of the market. However, the news that a current project doesn't have to support IE6 led me to trying out this CSS:

input[type="text"] { border: 1px solid #ccc; }

The attribute selector is mostly supported in IE7 and it allows me to restrict my borders to specific input types! Huzzah!