newcoder1010 Posted June 24, 2021 Share Posted June 24, 2021 Hello, <div class = "col-sm-4 col-xs-12 col-lg-4 col-md-4 col-sm-1 col-md-2"> doc </div> How can I style all of the class names with * so I do not have to individually write all of these? For example, I could style it like .col-sm-4, .col-xs-12 .col-lg-4 .col-md-4 .col-sm-1 .col-md-2{ color: red; } Instead, can I style these like that? But its not working for me. .col-*{ color:red; } Thanks! Link to comment Share on other sites More sharing options...
Ingolme Posted June 24, 2021 Share Posted June 24, 2021 (edited) You can use the attribute ^= selector on the class attribute. It would look something like this: [class^="col-"]. Though this will only match elements where the first class in the attribute begins with "col", it would not match <div class="something col-sm-4"> because the attribute starts with "something". Edited June 24, 2021 by Ingolme Link to comment Share on other sites More sharing options...
newcoder1010 Posted June 25, 2021 Author Share Posted June 25, 2021 Thank you! It worked. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now