wildcard in CSS for classes

0 votes

I have these divs that I'm styling with .tocolor, but I also need the unique identifier 1,2,3,4 etc. so I'm adding that it as another class tocolor-1.

<div class="tocolor tocolor-1">   tocolor 1   </div>
<div class="tocolor tocolor-2">   tocolor 2   </div>
<div class="tocolor tocolor-3">   tocolor 3   </div>
<div class="tocolor tocolor-4">   tocolor 4   </div>

.tocolor{
  background: red;
}

Is there a way to have just 1 class tocolor-*. I tried using a wildcard * as in this css, but it didn't work.

.tocolor-*{
  background: red;
}
Jun 10 in CSS by Edureka
• 7,940 points
9 views

1 answer to this question.

0 votes

Yes you can do this.

*[id^='term-']{
    [css here]
}

This will select all ids beginning with 'term-'.

As for the reason for not doing this, I can see why it would be desirable; as for style, I wouldn't do that, but it is feasible.

answered Jun 21 by Edureka
• 8,460 points

Related Questions In CSS

0 votes
0 answers

Setting the value of REM for all the properties in CSS

I would like to use rem everywhere ...READ MORE

Jun 21 in CSS by Edureka
• 7,940 points
14 views
0 votes
1 answer

small-caps font in css handles numbers as capital letters

Because numbers are not letters, they do ...READ MORE

answered May 28 in CSS by Edureka
• 8,460 points
19 views
0 votes
1 answer

nbsp not working in CSS content tag

May be this could be the solution ...READ MORE

answered May 28 in CSS by Edureka
• 8,460 points
21 views
0 votes
1 answer

What does !important mean in CSS?

The CSS! important rule is used to ...READ MORE

answered Jun 1 in CSS by Edureka
• 8,460 points
12 views
0 votes
1 answer

jQuery vs document.querySelectorAll

As seen above, querySelector() methodcan only be used ...READ MORE

answered Jun 14 in JQuery by gaurav
• 12,980 points
12 views
0 votes
0 answers

input[type='text'] CSS selector does not apply to default-type text inputs?

Text is the default input type. Since ...READ MORE

1 day ago in CSS by Edureka
• 7,940 points
6 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
4,471 views
0 votes
1 answer

How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags

I use jQuery for this: jQuery('li').wrapInner('<span class="li_content" />'); & ...READ MORE

answered May 27 in CSS by Edureka
• 8,460 points
29 views
0 votes
1 answer

CSS - Darken image except for rectangle overlay

Perhaps try constructing four boxes, one on ...READ MORE

answered May 28 in CSS by Edureka
• 8,460 points
23 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP