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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:22:59+00:00 2026-05-12T08:22:59+00:00

This may seem like a very basic question but I did not seem to

  • 0

This may seem like a very basic question but I did not seem to find an answer to it.
I know it is possible to define a css rule for more than one element at once as such:

.element1, .element2{
  font-size:14px;
}

Is it possible, though, to do that exact same thing, but apply the css to element after the css for element1 has been defined? Something like this:

.element1{
  font-size:14px;
}

/*later in the css... or in a separate file*/

.element2{
 like:".element1";
 font-weight:bold;
}

So that element2 now inherits the css of element one.
The reason I am trying to do this is because I have a css definition for an element1 that loads for all pages of the site. Then, for one particular page (that loads the main css file, along with its own) I would like to use the style from element1 and add to it.
What I am trying to avoid is loading the definition for element2 for all pages on the site (including those who don’t even have element[s] with the class element2.

Could this be done?
I realize I could easily achieve this with jQuery (i.e. $(".element2").addClass(".element1");) but I would like to avoid using scripts for my css.

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-12T08:22:59+00:00Added an answer on May 12, 2026 at 8:22 am

    You can use:

    <div class="element1 element2">
    

    while having

    .element1{
      font-size:14px;
    }
    
    .element2{
      font-weight:bold;
    }
    

    and so both classes will apply. jQuery is smart enough to add classes and remove classes like this.

    Also you can use something more advanced like SASS that alows mixins.

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

Sidebar

Ask A Question

Stats

  • Questions 173k
  • Answers 173k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you really do mean SVG, Inkscape should work. May 12, 2026 at 2:36 pm
  • Editorial Team
    Editorial Team added an answer The answer is in the question. Over time, it became… May 12, 2026 at 2:36 pm
  • Editorial Team
    Editorial Team added an answer What is the list of environment variables that I need… May 12, 2026 at 2:36 pm

Related Questions

Hiya - been pointed at you guys by a friend of mine. I have
Is there a (roughly) SQL or XQuery-like language for querying JSON? I'm thinking of
I'm just learning ruby on rails and I have a table of user roles
We are beginning to roll out more and more WAN deployments of our product

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.