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
• 11,040 points
61 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
• 9,540 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 in CSS by Edureka
• 11,040 points
67 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 in CSS by Edureka
• 11,040 points
23 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
• 9,540 points
98 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
• 9,540 points
134 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
• 18,960 points
189 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 in CSS by Edureka
• 9,540 points
99 views
0 votes
0 answers

Combinators in CSS

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

Jul 8 in CSS by Edureka
• 11,040 points
15 views
0 votes
0 answers

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

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

Jul 11 in CSS by Edureka
• 11,040 points
137 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 in CSS by Edureka
• 9,540 points
62 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
• 9,540 points
103 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