2

I know there's a way to select different ids with css to apply the same style., but i can't remember how.

What i mean is apply the same style to the divs below:

content-target1
content-target2
content-target3
content-target4

Any idea about this?

0

3 Answers 3

3

You can just use multiple ID selectors:

#content-target1, #content-target2, #content-target3, #content-target4

If you don't want to repeat the ID selectors, and/or you want to match them only by their common prefix, you can use an attribute selector instead (losing a bit of specificity, as ID selectors don't have wildcard matching capabilities like attribute selectors do):

div[id^="content-target"]
Sign up to request clarification or add additional context in comments.

Comments

0

"#id" is how you select an id, and "sel1, sel2" is how you select either sel1 or sel2 for a rule:

#content-target1, #content-target2 { background: red; }

1 Comment

sel1 "and" sel2 in case both are present.
0

Could you just do

#content-target1, #content-target2, #content-target3, #content-target4 {
CSS HERE 
}

edit: forgot my #s

1 Comment

you need to add # for id selection

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.