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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:40:25+00:00 2026-05-25T03:40:25+00:00

Back in the past I learned a lot about CSS but now I can’t

  • 0

Back in the past I learned a lot about CSS but now I can’t remember how to reuse styles.

Example:

I have some tabs with class tab and I can switch them with javascript. The current selected tab has another class, active.

Their CSS style:

.tab {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 0 15px 0;
    border: solid thin #CCC;
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
    color: #272F42;
    cursor: pointer;
    background-color: white;
}

.active {
    position: relative;
    top: 0;
    left: 0;
    padding: 15px 0 15px 0;
    border: solid thin #CCC;
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
    color: #272F42;
    cursor: default;
    background-color: #FFCF75;
}

Both styles has a lot of identic styles except 2, cursor and background-color.

So my question is, how can I resuse the .tab style and use it in .active?

I want achieve something like this:

.active { //extends .tab
    cursor: default;
    background-color: #FFCF75;
}

Thanks.

  • 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-25T03:40:25+00:00Added an answer on May 25, 2026 at 3:40 am

    You could, and probably should, apply both classes to the element like so:

    <a class="tab active"></a>
    

    If you want a css rule for the specific combination of these two classes, you’d do it like so:

    .tab {
        position: relative;
        top: 0;
        left: 0;
        width: 100%;
        padding: 15px 0 15px 0;
        border: solid thin #CCC;
        text-align: center;
        font-weight: bold;
        margin-bottom: 10px;
        color: #272F42;
        cursor: pointer;
        background-color: white;
    }
    
    .active 
    {
        cursor: default;
        background-color: #FFCF75;
    }
    
    .tab.active /* no space */
    {
        /* styles for elements that are both .tab and .active */
        /* leaving .active reusable for things other than tabs */
        /* and allowing override of both .tab and .active */
    }
    

    This allows you to avoid making unnecessary copies of your style declarations… and gives you the specificity to override either of the individual classes when an element has both.

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

Sidebar

Related Questions

I have been hearing a lot about the advantages of using a version control
I have failed submission (can't even get past upload verification) because my background agent
I have worked with globalization settings in the past but not within the .NET
I have used TransactionScope in the past with desktop client applications to roll back
You all have helped me so much in the past, I am coming back
I am learning android but I can't get past the InputStream.read(). This is just
You have been so helpful in the past that I keep coming back searching
Back in the past, i found a third party webpage that was able to
Looking back at my past projects I often encounter this one: A client or
I've dabbled with Haskell in the past, and recently got back into it seriously,

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.