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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:00:38+00:00 2026-05-19T02:00:38+00:00

Assume that I have some HTML page, and a corresponding CSS file. I’d like

  • 0

Assume that I have some HTML page, and a corresponding CSS file. I’d like to add rounded corners to some elements. I want to alternate background colors on every other section. I want to add a hover state for each section heading. So forth and so on – I keep styling and styling and styling.

It occurs to me that there are three extremes, where it concerns the “who, what, when, where, why and how” of distributing CSS rules over the markup by class, by id, and by hierarchy.

Extreme #1: Every style rule is based on an ID.

Extreme #2: Every style rule is based on a class.

Extreme #3: Every style rule is based on the DOM hierarchy.

Clearly, the zen of front-end web development would include a healthy balance of class reuse vs. unique rules vs. hierarchy, because any of the three extremes would wreak havoc on browser performance, maintainability, and code size. I think. Or am I wrong? How to tell when a new .class is necessary, or the style rules you want to apply can be safely shoe-horned into an existing definition? When are two #id rules similar enough that you should pull common code out into a class? When do you “fork” a class (sometimes you keep the original, and add derivations for all deviate situations (“percolate” in OOP terms), and other times push common rules down into each of the several disjoint deviations – clearly this depends upon the nature (ie, number of rules involved) in the deviation itself). Are there just circumstances for using purely hierarchical rules?

Question: Are there any rules of thumb governing this sort of debate? What is your experience and/or advice? Are there good articles, resources, books, lectures (bonus points for “tech talk” style videos), or other content available on the topic? I’d like to keep the discussion grounded in a few key points (although any commentary is welcome), in no particular order:

  • Maintainability (ease of reading, modifying, and adding code)
  • DRY (Don’t Repeat Yourself)
  • Time efficiency (time-to-onload; progressive rendering)
  • Space efficiency (combined size of the markup & associated styles)
  • 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-19T02:00:38+00:00Added an answer on May 19, 2026 at 2:00 am

    Do yourself a favor, check out SASS.

    While there are pros and cons to compiling your CSS, the gains from having real variables, mix-ins, and helpers in your pre-compiled CSS is definitely worth at least passing consideration.

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

Sidebar

Related Questions

When Connected: I have a simple HTML page with some image elements that reference
Assume that I have a HTML file as myweb.html in C:\ directory. And some
Assume some domain and view objects (that have no common base class) public class
Assume that we have a large file which can be read in chunks of
Assume I have 2 controllers that handle 2 parts of the page - header
I have a fairly large page, which contains lots of css and html. The
I have some code that effectively does this : File file = new File(C:\\Program
For some reason I have always assumed that most of the time a variable
Assume that we have two sets: A=(a_1,a_2,...,a_m) and B=(b_1,b_2,...,a_n) (Not necessarily of same size).
Assume that i have created a client TCP Socket in Activity A. I want

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.