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

  • SEARCH
  • Home
  • 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 6380199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:14:13+00:00 2026-05-25T02:14:13+00:00

I have p.first_p:first-letter in my stylesheet, as I checked, it works well when class

  • 0

I have p.first_p:first-letter in my stylesheet, as I checked, it works well when class first_p is set in HTML. Problems start when I use javascript to find elements and then set their class.

Under Chrome and Opera it works fine (I need to check IE 8 and 9, and FF3).

FF 5.01 changes the class, but still pseudo class setting doesn’t affect the element.

It seems that FF needs to ‘refresh’ css settings of element before pseudo class starts working, so I made rather dirty workaround – script replaces affected node with its clone.

Is there a better way to solve that issue? Some way to make FF recalculate everything it knows about node? Also that workaround isn’t enough for IE 7.

Edit: yeah, pseudo-element not pseudo-class, my bad

  • 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-25T02:14:14+00:00Added an answer on May 25, 2026 at 2:14 am

    Is it possible to not use javascript?

    I’m guessing that you’re applying first_p to the first paragraph of particular elements.
    It possible for you to use the :first-child selector instead?

    I’m not sure if this will work, but you could try something like the following, assuming you want to apply this to children of divs with class “copy”

    .copy p:first-child:first-letter{
      color: #abcdef; /* or whatever */
    }
    

    this definitely works and you don’t need javascript, except for crappy old IE.

    Alternatively you could try this:

    .element p:first-letter{
      font-size: 20px;
    }
    
    .element p + p:first-letter{
      font-size: inherit;
    }
    

    This css makes any paragraph that is not preceded by another paragraph have a styled first letter. Would that solve your problem?

    Wait, you want it to work in Firefox. Try this:

    .element p:first-of-type:first-letter{
      font-size: 20px;
    }
    

    It selects the first matching element. The :first-of-type pesudo-element is supported by Firefox, Opera, Chrome and Safari according to SitePoint’s page for :first-of-type

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

Sidebar

Related Questions

This code explains pseudo elements first-letter and first-line and it's working fine. <html> <head>
I have a sliding boxcaption and it works fine. But when you first view
I have two separate dictionaries. First one has letter's equivalent icon names, and the
I have the following paragraphs: <p>This is a first paragraph.</p> <p>This is a second</p>
I have first: select url from urls where site = '$value' order by url
I have first names stored in one table and last names stored in another.
Bascially you have first to do a: SurfFeatureDetector surf(400); surf.detect(image1, keypoints1); And then a:
I have Depth first searching algorithm whose pseudo code is given below: DFS(Vertex v)
I have my first ever interview for a Java developer role, specifically RMI, Serverlets
I have my first professional assignment of making a website in which a photographer's

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.