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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:21:14+00:00 2026-05-20T18:21:14+00:00

Say I have two classes in my CSS, say .classA{} and .classB{} , and

  • 0

Say I have two classes in my CSS, say .classA{} and .classB{}, and I’ve defined and tailored classA to however I like it. Now I’d like classB to be mostly like classA, with a couple of changes. Since they will be used separately (i.e., A is not the parent of B), B won’t inherit properties from A in the layout. Can I do something like

.classB{
    from .classA inherit *
    some additional changes
}

while writing the CSS, which will avoid having to copy/paste and also ensure that if I were to change A sometime later, B changes automatically and I don’t have to keep track of it.

  • 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-20T18:21:14+00:00Added an answer on May 20, 2026 at 6:21 pm

    CSS has no concept of variables to allow for the adjusting of one CSS measurement to influence others automatically. However, there are CSS writing systems that allow for variables (that are then ‘compiled’ and spit out plain CSS). Those are useful, but require use of the particular framework. (one example: http://lesscss.org/ )

    If you are using a server side scripting language such as PHP, you could write your CSS files as PHP files, using variables within.

    Barring that, I’d use multiple classes:

    .sharedStyles {...the styles to be the same on elements}
    .uniqueStylesA {...}
    .uniqueStylesB {...}
    

    Then apply as such:

    <div class="sharedStyles uniqueStylesA">...</div>
    <div class="sharedStyles uniqueStylesB">...</div>
    

    Or…if you can nest in your HTML:

    <div class="sharedStyles">
        <div class="uniqueStylesA">...</div>
        <div class="uniqueStylesB">...</div>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have two type classes defined as follows that are identical in function
Let's say I have two classes like the following: Class A { public: ..
Say I have a div that uses two css classes that both use text-align,
Say I have two classes like this: class A{ private static Random random =
Let's say we have two classes, Foo and Foo Sub, each in a different
I have got two classes, one a subclass of the other (say Animal and
Let's say I have two models, Classes and People. A Class might have one
Say I have two classes and have a requirement that the primary key property
Say you have two classes, A and B. Is it possible to instantiate both
Say I have two classes which extend Event : public class CustomEventOne extends Event

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.