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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:20:44+00:00 2026-05-26T10:20:44+00:00

I have a span with 2 classes, like this <span class=tag invalid_tag>abc</span> . I

  • 0

I have a span with 2 classes, like this <span class="tag invalid_tag">abc</span>. I add the second class through jQuery correctly and i need the properties from the second class to override the first, without actually removing it. For instance, the properties are the font color and background-color. Usually the tag is green but when i add the class “invalid_tag” it should turn red but it doesn’t because the first class has the priority. I would like to know how to change this priority, or if i can achieve this in a different way.

  • 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-26T10:20:44+00:00Added an answer on May 26, 2026 at 10:20 am

    The priority of CSS declarations relies on their order in the CSS (later declarations override earlier ones) and their specificity (more specific declarations override less-specific ones). (It has nothing to do with the order you specify the class names in the attribute.) More in Section 6 the specification.

    Here’s an example of order. This CSS

    .foo {
        color: red;
    }
    .bar {
        color: blue;
    }
    

    with this HTML

    <p class="foo bar">Hi there</p>
    <p class="bar foo">Hi again</p>
    

    …results in two blue paragraphs, because the second declaration takes precedence over the first. (Live example) That happens because both declarations have the same specificity.

    Here’s a demonstration of specificity:

    This CSS

    p.foo {
        color: red;
    }
    .bar {
        color: blue;
    }
    

    …with the same HTML results in two red paragraphs, because the selector p.foo is more specific than the selector .bar, so it takes precedence even though it’s earlier in the CSS. (Live example)

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

Sidebar

Related Questions

I have some message elements like this... <span class=error message>Whoops! Don't forget your name.</span>
I have a span that is generated through javascript, with its css class as
How does the Block component handle CSS classes? I have code like this: <style
is it possible to add some kind of class like 'arrow' or a span
I have a span element inside a table td element. The span tag has
I have two span elements that I would like to stay on the same
Suppose I have a span: <span class=myspan></span> .myspan{ background: url(image.png) top left no-repeat; }
I have the following: $(span.findme).each(function() { $(<li>).text($(this).text()).appendTo(ul); }); How can I, using the above,
I have: <div class=ui-widget> <div class=ui-widget-header> <span class=ui-icon ui-icon-circle-triangle-n>My Menu</span> </div> <ul class=ui-widget-content> <li>Menu
I have a class that inherits from TreeNode, called ExtendedTreeNode. To add an object

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.