CSS3 selector first-of-type with class name

0 votes

Is it possible to choose the first element with a specific class name using the CSS3 selector:first-of-type? I've had no luck with my test, so I'm assuming it's not.

p:first-of-type {color:blue}
p.myclass1:first-of-type {color:red}
.myclass2:first-of-type {color:green}
<div>
  <div>This text should appear as normal</div>
  <p>This text should be blue.</p>
  <p class="myclass1">This text should appear red.</p>
  <p class="myclass2">This text should appear green.</p>
</div>
Aug 17 in CSS by Edureka
• 11,040 points
19 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In CSS

0 votes
1 answer

when declaring css styles, what is the meaning of .classA.classB (two class names with a dot in the middle and no space)

The first example (space-separated classes) is a ...READ MORE

answered Jun 28 in CSS by Edureka
• 9,540 points
47 views
0 votes
1 answer
0 votes
0 answers

Looping Animation of text color change using CSS3

I have text that I want to ...READ MORE

Jun 22 in CSS by Edureka
• 11,040 points
66 views
0 votes
0 answers

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

Text is the default input type. Therefore, ...READ MORE

Aug 12 in CSS by Edureka
• 11,040 points
28 views
0 votes
0 answers

Maintain the aspect ratio of a div with CSS

I want to make a div that ...READ MORE

Aug 19 in CSS by Edureka
• 11,040 points
20 views
0 votes
2 answers

Uncaught TypeError: Cannot read property 'setState' of undefined

Use this.delta() = this.delta.bind(this); in place of this.delta. ...READ MORE

answered Aug 22, 2020 in CSS by Abhishek
11,724 views
0 votes
1 answer

wildcard * in CSS for classes

Yes you can do this. *[id^='term-']{ ...READ MORE

answered Jun 21 in CSS by Edureka
• 9,540 points
65 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
214 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
115 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
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