tkbx
tkbx

Reputation: 16275

CSS for multiple attributes?

I'm trying to consolidate the following:

input[type="text"] {
    width: 300px;
}
input[type="password"] {
    width: 300px;
}

Into something like this:

input[type="text"][type="password"] {
    width: 300px;
}

I tried this, type="text", "password", and a few other things.

Upvotes: 2

Views: 44

Answers (2)

Scott
Scott

Reputation: 21882

Or simply

input { width: 300px; }

Then apply any other styles via type selectors

input[type="text"] { background: #ffd; }
input[type="password"] { background: #fff; }

Upvotes: 1

Dipesh Parmar
Dipesh Parmar

Reputation: 27364

You can use many selectors as you want with commas,

input[type="text"],input[type="password"] {
    width: 300px;
}

Upvotes: 7

Related Questions