Jump to content

How to style div class


Recommended Posts


<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. 



Link to comment
Share on other sites

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 by Ingolme
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...