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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:33:58+00:00 2026-05-25T20:33:58+00:00

I have a style set for many divs that looks similar. The only difference

  • 0

I have a style set for many divs that looks similar. The only difference is that each div has different padding and margin setup. Something like this:

<div class="mainStyle" id="cc">CC</div>
<div class="mainStyle" id="bb">BB</div>
<div class="mainStyle" id="aa">AA/div>

And have:

.mainStyle {
    float: right;
    width: 60px;
    text-align : center;
    font: 95% Arial;
    -moz-border-radius: 5px;
    border-radius: 5px;
    background : #69abd0;
}

And for each id have only:

#aa {
    margin: 0px 2px 0px 2px;
    padding: 2px 0 5px 0;
}

#bb {
    margin: 10px 2px 10px 2px;
    padding: 2px 0 5px 0;
}

#cc{
    margin: 10px 2px 10px 2px;
    padding: 20px 0 50px 0;
}

I know this is the wrong syntax but I don’t know how else to ask the question…
I don’t want to have a long style definition for each element id because they are %90 the same except the padding and margin. I want to somehow combine the style of the class and the element.

How do I do this?

  • 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-25T20:33:58+00:00Added an answer on May 25, 2026 at 8:33 pm

    What you’ve written will accomplish what you’re asking. You do have a syntax error in your code, the tag for the final AA element is missing the left <. Also, just remember that order is important when it comes to CSS styles. The styles for the id’s needs to come after .mainStyle and any other styles that may overwrite your margin or padding. You can overcome this necessity by using the !important modifier on your styles.

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

Sidebar

Related Questions

I have form that has a restricted size and the overflow style set to
I have a UITableView that uses the UITableViewCellStyleDefault style. I also have set the
I have a div tag styled through CSS. I set the padding to 10px
I have a grid of many images and each image has a CSS class
Flash UI Components have many different styles to set, which require passing a string
I have many elements (floating href tags) in a div with a set height/width,
I have a UISegmentedControl on a black UIToolbar. I have set the style to
I have a TComboBox on a form. Its Style property is set to csDropDownList.
I have a set of Java 5 source files with old-style Doclet tags, comments
I have a MySQL database set-up in a hierarchy style. There are 4 tables

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.