Web_Designer
Web_Designer

Reputation: 74640

CSS selector to select element that has this id and this class

Can you select an element with CSS that has a certain id and a certain class?

Something like this I suppose:

#id.class {
    color: blue;
}

Upvotes: 0

Views: 13268

Answers (1)

Chris
Chris

Reputation: 8024

Let's say you have a class people. Their background-color is white. But if you refer to special people like alice or bob, you can use IDs to make them look special.

.people {
 background-color: white;
}

.people#alice {
 text-transform: capitalize;
}

.people#bob {
 text-transform: uppercase;
}

What are your intentions? If you want to have a generic people class and special alice and bob you could also use:

CSS:

.people {
 background-color: white;
}

#alice {
 text-transform: capitalize;
}

#bob {
 text-transform: uppercase;
}

and HTML:

<div class="people" id="alice">Alice</div>
<div class="people" id="bob">Bob</div>

Upvotes: 7

Related Questions