Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 515523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:38:13+00:00 2026-05-13T07:38:13+00:00

While practicing different scenarios in which CSS3 pseudo-classes and selectors might come in handy,

  • 0

While practicing different scenarios in which CSS3 pseudo-classes and selectors might come in handy, I ran across something I just can’t figure out!

Here’s the situation. I want to modify the :first-of-type::first-letter of the first non-empty paragraph for a block of text. I’m not sure that pseudo-classes can be stacked though. Here’s what I’ve come up with (Doesn’t work, of course)

.article-body > p:not(:empty):first-of-type::first-letter { ... }

Given the following markup:

<div class="article-body">
    <p></p>
    <p>The "T" in this paragraph should be the one affected.</p>
</div>

The only guess I can come up with is that pseudo-classes (ie; :not() and :first-of-type) can not be stacked upon each other. Which is odd since you can stack pseudo-elements upon each other, and other pseudo-classes…

Any ideas for how this can be accomplished?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:38:13+00:00Added an answer on May 13, 2026 at 7:38 am

    :first-of-type selects the first p, as the name suggests, not the first non-empty p as you might want.

    They stack just fine, but :first-of-type purely operates on the tag (i.e. type), not on the preceding complex selector. So you just end up looking for the first p, and that first paragraph also shouldn’t be empty. And that doesn’t exist.

    Assuming empty paragraphs might appear throughout the text, and you only want the first, non-empty paragraph to be affected, I don’t think it’s possible to do this with just one selector. This is the best I can come up with:

    p:first-of-type::first-letter,
    p:empty + p::first-letter { text-transform: uppercase; /* ... */ }
    
    p:not(:empty) ~ p::first-letter { text-transform: inherit; /* reset */ }
    

    That will apply the CSS only to the first non-empty paragraph (well, and to a first empty paragraph, but it won’t do anything then anyway).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 261k
  • Answers 261k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer These slides [PDF] describe a DHT that uses IDA (Information… May 13, 2026 at 11:30 am
  • Editorial Team
    Editorial Team added an answer Android provides no way to change the locale of your… May 13, 2026 at 11:30 am
  • Editorial Team
    Editorial Team added an answer think there's a typo, the code assigns (with one equals… May 13, 2026 at 11:30 am

Related Questions

While practicing the jxl API, i cant extract details from certain Excel sheet its
I am practicing making a web app which tries to read the user's twitter
I have been practicing TDD in C# for several years now and recently have
I'm practicing for the upcoming ACM programming competition in a week and I've gotten
I am practicing using pointers. I have a pointer to an array of 3

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.