2

I have following elements:

<div class="grid">
   <div class="col-1">First Col</div>
   <div class="col-center-2">Second Col</div>
   <div class="col-center-3">third Col</div>
   <div class="col-3">third Col</div>
</div>

i want to add class for all elements which have "-center-" word on that. how i can define this selector?

1

1 Answer 1

6

You can use [attr*=value] attribute selector

div[class*="-center-"] {
  color: red;
}
<div class="grid">
  <div class="col-1">First Col</div>
  <div class="col-center-2">Second Col</div>
  <div class="col-center-3">third Col</div>
  <div class="col-3">third Col</div>
</div>

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.