CSS 2 Attribute selectors
January 6th, 2006 by Sonja DuijvesteijnA lot of good stuff can be done with CSS 2 (w3c recommendation 1998), but unfortunately a lot of it is still badly supported. However, with the new browsers (firefox, IE7 soon) a lot more of CSS 2 will be implemented. One of the cool things you can use is the attribute selector.
Suppose you have a form, with a password box, which you want to style differently from normal text fields.
<input type='password' name='pass1' >
<input type='password' name='pass2' >
Now, with CSS 1 you would have to give this input field a specific class, id or style to change this. But no more.
input[type="password"] {
font-weight: bold;
}
A number of these can even be linked together, so you can differ between the first password field and the second!
input[type="password"][name='pass2'] {
color: silver;
}
Related posts
CSS 3 selectors
Font-sizes in css: em ex px, mm cm in pt pc, %
More CSS
X-path for beginners
March 6th, 2009 at 7:33
Very good site! Thanks! faithbase
Buy cheap alprazolam online