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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:47:41+00:00 2026-06-13T08:47:41+00:00

I have a problem here that i can’t seem to figure out, till now

  • 0

I have a problem here that i can’t seem to figure out, till now my css has been a little slapdash and it was always a case of hack away till it looks right but i’ve decided to learn it properly and i’m trying to categorize things as much as i can.

So i have a layout that has an unordered list, this list has three li tags, within each of these li tags are two div each.

Now i have a class for each of these containers, they can be called container_1 container_2 and so on.

Now they have some unique attributes to each of them but they al also follow a set style for example, the divs in each li are side by side so its sets of two divs also they are all going to have round corners.

So i thought i could make a class class rounded_corners plus float_left and float_right so instead of re typing the code to round the corns or float something i could just reference thing class like this:

.container_1 .rounded_corners .float_left
{

}
 .container_2 .rounded_corners .float_right
{

}

But when i use this i loose my styling so i used a comma and this allowed the sty;ing for the div to come back but the corners and floats didn’t work.

So where am i going wrong with this?

This is my code, i have taken the code out that breaks the layout, but if you remove the comments you can see what happens.

http://jsfiddle.net/ragebunnykickass/g3Zaz/

The naming is a little different but you’ll know what is meant.

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-06-13T08:47:42+00:00Added an answer on June 13, 2026 at 8:47 am

    CSS classes cannot inherit so what you have to do is split them to be as much atomic as possible. For example if you have a rounded-corners class and it may be applicable to containers:

    .rounded-corners
    {
       /* Your CSS to define rounded corners */
    }
    

    Note that you define ONLY the properties for rounded corners. Now let’s say you have a class to style containers (for example with a proper padding):

    .container
    {
        /* Your CSS to define a nice container */
    }
    

    How to combine them together? This won’t be done in CSS but in HTML, in this example this <div> inherits from both container and rounded-corners:

    <div class="container rounded-corners">
    </div>
    

    Now suppose you need rounded corners for a non container object:

    <div class="rounded-corners">
    </div>
    

    This is how CSS works. Do not compare them (because of name) with classes of object oriented languages. Each class define a set of attributes that will be applied to all elements that belong to that class. Final element style is the composition of the attributes inherited from each class that element belongs to.

    NOTE: to summarize: answer is yes, you may have to repeat some code. You’ll have trouble to manage your code (both HTML and CSS) if you use classes as short names for a style: you’ll see you missed the point to separate content from style (because in HTML you’ll define, using a class like rounded-corners, an explicit appearance). Imagine: next month you have to change your web-site style and fashion requirements impose you have square corners. You have to change your HTML code (unless you accept to have a rounded-corners class to apply a squared border). Much better if you simply say container and you let your CSS to define (and know) how a container should be rendered.

    It may be applicable to you or not (it depends on your preferences, taste and development environment) but you may take a look to LESS. It’s implemented as a JavaScript that will parse your CSSs. Of course you won’t write a pure valid CSS but you’ll gain many new features. In your case you may find mixins are what you need:

    .rounded-corners
    {
        /* Your CSS here */
    }
    
    .float-left
    {
        /* Your CSS here */
    }
    
    .container
    {
        .rounder-corners
        .float-left
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem at hand here that I can't seem to figure out.
I seem to have a bit of a problem here that I can't quite
I have a small problem here and hope that someone can help me out.
I have a little dilemma that maybe you can help me sort out. I've
I have a problem here that requires to design a data structure that takes
Updated Problem solved, I have some design problem here. The directory looks like that:
my first question here! I have a problem with a piece of code that
So here is the problem: I have some logic in my application that will
Here's the core problem: I have a .NET application that is using COM interop
Here's my problem: I have an unmanaged dll that I made.I'm calling one of

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.