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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:56:13+00:00 2026-05-27T17:56:13+00:00

Is it better/faster to (1) stack selectors in style declarations, (2) stack classes in

  • 0

Is it better/faster to (1) stack selectors in style declarations, (2) stack classes in HTML tags, or (3) stack duplicate declarations in unique selectors?

To clarify my question, I will show you examples of each. Each piece of code should accomplish the same end goal, but I’m not sure if one will ultimately be faster to load or whether it is just a matter of preference.

1 (class selectors are duplicated):

<style>
.one, .two, .three {color:white}
.one, .two {background:blue;height:30px}
.one, .three {width:800px}
.two, .three {font-size:16pt}
.one {font-size:10pt}
.two {width:650px}
.three {background:#333}
</style>
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>

2 (inline classes are duplicated):

<style>
.white {color:white}
.bluebg {background:blue}
.heightThirty {height:30px}
.widthEight {width:800px}
.sizeSixteen {font-size:16pt}
.one {font-size:10pt}
.two {width:650px}
.three {background:#333}
</style>
<div class="one white bluebg heightThirty widthEight"></div>
<div class="two white bluebg heightThirty sizeSixteen"></div>
<div class="three white widthEight sizeSixteen"></div>

3 (declarations are duplicated):

<style>
.one {color:white; background:blue; height:30px; width:800px; font-size:10pt}
.two {color:white; background:blue; height:30px; font-size:16pt; width:650px}
.three {color:white; width:800px; font-size:16pt; background:#333}
</style>
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>

I used to create sites using the third method, but I found it difficult to change values, if I decided to change the colour scheme of a site, for example. I would have to do a find/replace for background:blue and change it to something else (but find/replace can prove ineffective if I’m being less than consistent). Now I use a combination of the first and second method, with a preference for the first. I decide which elements should share style declarations, and group them together in the stylesheet.

The first method uses less characters (at least in this example), so I know it would make for a smaller filesized HTML file, but I’m not sure about loadtime; and there could be other things I’m unaware of.

Is there a method which ought to be used? I’ve pointed out the problem that can come with the third method, but are there other problems (with any three) that I don’t know about?

  • 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-27T17:56:14+00:00Added an answer on May 27, 2026 at 5:56 pm

    I like the 3rd method and 1st method.

    When working on most sites, I try to use the 1st service, without duplicating selectors in so many places (just a few) so that they remain in control.

    When using 3rd method, it can be a nightmare to refactor, here comes the role of other languages that translate to CSS, namely SASS and LESS. Those languages allow you to store repeated parts in variables and functions (called “mixins” usually).

    I think you’ll love LESS http://lesscss.org/ a lot. I jumped to an existing project using it to create some special reusable UI widgets and all CSS was using LESS, and without prior knowledge it was easy enough to understand existing code, and write new parts. Recommended for new websites, while it or 1st method are fine for existing sites.

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

Sidebar

Related Questions

Just an academic question. I'm curious what version of this code is better (faster)
Which one is better/faster/preferred 1: mov eax, 5 push eax mov eax, [someAddress] push
Which of these two statements is faster/better practice? myList.Where(x => { bool itemOne= x.ItemOne
Is it better (more efficient, faster, more secure, etc) to (A) cache data that
Try to see which cast is faster (not necessary better): new c++ case or
Is there a better, more elegant (and/or possibly faster) way than boolean isNumber =
Between HtmlSelect and DropDownList, which one has a better performance (initialized and rendered faster)?
I'm looking for some data to help me decide which would be the better/faster
Is it better/faster to use a global variable when doing things within .each()? over
I was wondering which is a better/faster/more efficient way of turning arbitrary strings into

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.