2

I have 5 buttons on my page and I want to style their CSS so they would be different, I don't know how to do that. Here is the code:

<input input class='field' type='button' name='a4' value='A4'/>
<input input class='field' type='button' name='a3' value='A3'/>
<input input class='field' type='button' name='a2' value='A2'/>
<input input class='field' type='button' name='a1' value='A1'/>
<input input class='field' type='button' name='a'  value='A'/>

should CSS looks like this:

.field {
    width: 120px;
}

.field a1 {
    width: 220px;
}

1 Answer 1

1

You could use the attribute selector:

.field[name='a1'] {
    color: blue;
}

It is very well-supported across all major browsers. A demo is available here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.