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 7934981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:47:04+00:00 2026-06-03T21:47:04+00:00

I was wondering if there’s a way to add a CSS class to pseudo-elements,

  • 0

I was wondering if there’s a way to add a CSS class to pseudo-elements, such as :after.

I want to use :after to append an error message. I also want the error message styled the same way as the other error messages.

This works:

.error:after {
  content: "Error Message";
  color: red;
}

But can I do something like this to add more than the color styling?:

.error:after {
  content: "Error Message";
  class: error_message_styles;
}

Also, is there a difference between using “::after” vs “:after”?

Thanks in advance!

  • 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-06-03T21:47:06+00:00Added an answer on June 3, 2026 at 9:47 pm

    There’s no way to give an HTML attribute of any kind to a psuedo element.

    Just use the selector twice:

    .error:after {
      content: "Error Message";
    }
    .error:after, .error-style {
      color:red;
    }
    

    Also, is there a difference between using “::after” vs “:after”?

    According to this:

    https://developer.mozilla.org/en/CSS/:after

    The ::after notation was introduced in CSS 3 in order to establish a
    discrimination between pseudo-classes and pseudo-elements. Browsers
    also accept the notation :after introduced in CSS 2.

    Note: Microsoft Internet Explorer 8 supports the :after notation
    only.

    I would argue that error messages might be content, not decoration – but that’s your call.

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

Sidebar

Related Questions

Wondering whether there is an efficient way to add an item to Java's ArrayList
Wondering if there’s a plugin or best way of setting up an ActiveRecord class
Just wondering if there is an easy way to add the functionality to duplicate
Wondering if there is a way to use a python script to attempt a
Wondering if there is a way to change the left css value of this
Wondering if there is any way to get the lambda expressions that result from
Wondering if there is a good way to generate temporary URLs that expire in
Just wondering if there is any way to get the NS records in C#.
Just wondering if there is a way in Spring to have a parent controller:
Wondering if there is a way I could trigger an event, so that any

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.