0

I have multiple css styles:

form#reply_form-c1r1.odgovor div#cmtforms-c1r1 input{color:red}
form#reply_form-c2r1.odgovor div#cmtforms-c2r1 input{color:red}
form#reply_form-c3r1.odgovor div#cmtforms-c3r1 input{color:red}
form#reply_form-c4r1.odgovor div#cmtforms-c4r1 input{color:red}

and I want to make the one css style like this

form[id^="reply_form-c"]r1.odgovor div[id^="cmtforms-c"]r1 input{color:red}

But this code, doesn't work..

What I missed?

1
  • 1
    [id^="..."]r1 will not work. [id^="..."][id$="r1"] will. Commented Feb 10, 2023 at 0:24

1 Answer 1

0

Just give the elements a class and use that not all the id's etc. class="red-block" and then in CSS .red-block{color:red;}

Example:

.red-block {
  color: red;
}
<div class="red-block">Howdy</div>
<span class="red-block">spanner</span>
<button type="button" class="red-block">Make me do it</button.

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

5 Comments

OK, good thought but I can't use that. I need to use wildcard css like I show in my example.
That then becomes a different question and is a duplicate: here is a good answer: stackoverflow.com/a/11496658/125981
That also show the "endswith" example
And here is a "contains" example: stackoverflow.com/a/12157322/125981
FWIW and IMHO using ID's in any way to style is kind of an anti-pattern.

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.