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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:30:46+00:00 2026-06-11T18:30:46+00:00

Why do people use this kind of CSS and HTML to style their pages?

  • 0

Why do people use this kind of CSS and HTML to style their pages?

<div class="page">
  <div class="page-left-column">
    <div class="page-left-column-container-box">
      <div class="page-left-column-container-box-element-header-wrapper">
         <h2>This is the header!</h2>
      </div>
    </div>
  </div>
</div>

The above markup would be accompanied by CSS rules like this:

.page-left-column-container-box-element-header-wrapper {
  color: red;
}

Why not write it like this:

<div class="page">
  <div class="left column">
    <div class="container-box">
      <div class="element header-wrapper">
         <h2>This is the header!</h2>
      </div>
    </div>
  </div>
</div>

And then make the CSS rule (perhaps not all of this would be required):

.page .left.column .container-box .element.header-wrapper {
  color: red;
}

As far as I can see, the latter is much superior to the first one. It is easier to specify CSS rules without having to copy-paste everything all over the place because you can specify rules like .container-box .element and .column .header-wrapper. In my opinion, this also makes the rules, code and everything more maintainable. The only downside to this is that if you write CSS rules like this: .page .left.column .container-box .element.header-wrapper then the selector will have a dependency to a deep HTML hierarchy. However, the page-left-column-container-box-element-header-wrapper may not have such a hard dependency to the hierarchy but obviously changing the hierarchy would make one want to update the “false” class name, would it not?

The only reason I can imagine for using class names like page-left-column-container-box-element-header-wrapper is that perhaps using slightly more “complex” selectors is computationally expensive and makes the browser slow. Can this be true? Are there other programming-related/technical advantages that I’m just not seeing? Or is it just that rules that use multiple elements, classes and ids are complicated?

  • 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-11T18:30:47+00:00Added an answer on June 11, 2026 at 6:30 pm

    Both of those are poor examples of CSS.

    CSS like:

    .page .left.column .container-box .element.header-wrapper 
    

    is far too specific, meaning it’s re usability is minimal.

    CSS like:

    .page-left-column-container-box-element-header-wrapper
    

    Is just too long a word. You could easily shorten the name down to something like:

    header-wrapper
    

    Which means it could be used elsewhere in code quite easily, and you can easily identify what the element is for, it wraps a header.

    CSS Specificity:

    • http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html
    • http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/
    • http://css-tricks.com/specifics-on-css-specificity/

    Please note, I do not agree fully with some of the content on these links, such as “never” using IDs

    Put simply, people use those methods because they don’t know any better half of the time.

    Naming conventions is quite a subjective topic however, I personally believe CSS classes & IDs should be under 20 characters always, if not 10. BUT, they should be understandable. For example:

    .pg-fl-r
    

    Is poor … whereas:

    .float-right, .page-float-r
    

    etc is a nicer way. (This is just an example, I wouldn’t necessarily recommend having classes named like that.)

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

Sidebar

Related Questions

Typically, I've seen people use the class literal like this: Class<Foo> cls = Foo.class;
I've seen people doing things like this in their HTML: <!--[if IE]> <link rel=stylesheet
Many people use this method to add animation on switching views. When I try
I'm interested in how people use this feature: what domain, what relationships (apologies if
I've seen people use many-to-one mappings to represent one-to-one relationships. I've also read this
In view pages, people use form tag helpers and link helpers etc. If I
In Java people often define an interface together with a class and use interface
What kind of graphical frameworks/technologies do they use to understand and draw CSS instructions?
People use gdb on and off for debugging, of course there are lots of
Why do people use enums in C++ as constants when they can use const

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.