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, 2022 in CSS by Edureka
• 13,620 points
627 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, 2022 by Edureka
• 12,690 points

Related Questions In CSS

0 votes
0 answers

Using CSS for a fade-in effect on page load

Can a text paragraph fade in on ...READ MORE

Jul 29, 2022 in CSS by Edureka
• 13,620 points
1,096 views
0 votes
0 answers

what do css classes like my-2, my-lg-0, mr-sm-2 do in bootstrap 4?

I've read through other queries and the ...READ MORE

Aug 18, 2022 in CSS by Edureka
• 13,620 points
1,297 views
0 votes
1 answer

CSS - Darken image except for rectangle overlay

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

answered May 28, 2022 in CSS by Edureka
• 12,690 points
719 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, 2022 in CSS by Edureka
• 12,690 points
1,357 views
0 votes
1 answer

jQuery vs document.querySelectorAll

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

answered Jun 14, 2022 in JQuery by gaurav
• 23,260 points
4,563 views
0 votes
1 answer

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

Because that is not what it is ...READ MORE

answered Jun 28, 2022 in CSS by Edureka
• 12,690 points
1,588 views
0 votes
0 answers

Combinators in CSS

everyone! I am quite new to HTML ...READ MORE

Jul 8, 2022 in CSS by Edureka
• 13,620 points
335 views
0 votes
0 answers

CSS :not(:last-child):after selector

I have a list of elements, which ...READ MORE

Jul 11, 2022 in CSS by Edureka
• 13,620 points
2,417 views
0 votes
1 answer

Setting the value of REM for all the properties in CSS

We've covered this in comments, but essentially ...READ MORE

answered Jun 28, 2022 in CSS by Edureka
• 12,690 points
2,038 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, 2022 in CSS by Edureka
• 12,690 points
1,032 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP