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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:12:54+00:00 2026-05-15T01:12:54+00:00

As I was working on a small website, I decided to use the PageSpeed

  • 0

As I was working on a small website, I decided to use the PageSpeed extension to check if their was some improvement I could do to make the site load faster. However I was quite surprise when it told me that my use of CSS selector was “inefficient”. I was always told that you should keep the usage of the class attribute in the HTML to a minimum, but if I understand correctly what PageSpeed tell me, it’s much more efficient for the browser to match directly against a class name. It make sense to me, but it also mean that I need to put more CSS classes in my HTML. It make my .css file harder to read.

I usually tend to mark my CSS like this :

#mainContent p.productDescription em.priceTag { ... }

Which make it easy to read : I know this will affect the main content and that it affect something in a paragraph tag (so I wont start to put all sort of layout code in it) that describe a product and its something that need emphasis. However it seem I should rewrite it as

.priceTag { ... }

Which remove all context information about the style. And if I want to use differently formatted price tag (for example, one in a list on the sidebar and one in a paragraph), I need to use something like that

.paragraphPriceTag { ... }
.listPriceTag { ... }

Which really annoy me since I seem to duplicate the semantic of the HTML in my classes. And that mean I can’t put common style in an unqualified

.priceTag { ... }

and thus I need to replicate the style in both CSS rule, making it harder to make change. (Altough for that I could use multiple class selector, but IE6 dont support them)

I believe making code harder to read for the sake of speed has never been really considered a very good practice . Except where it is critical, of course. This is why people use PHP/Ruby/C# etc. instead of C/assembly to code their site. It’s easier to write and debug. So I was wondering if I should stick with few CSS classes and complex selector or if I should go the optimisation route and remove my fancy CSS selectors for the sake of speed?

Does PageSpeed make over the top recommandation? On most modern computer, will it even make a difference?

  • 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-15T01:12:54+00:00Added an answer on May 15, 2026 at 1:12 am

    should I make my CSS easier to read or optimise the speed?

    You should do both.

    You should write your CSS so it is readable and if you want to collapse it, use a tool that automates that to generate the “production CSS”.

    So you should be working with nice readable blocks and the published file should be tiny.

    In terms of the specific selectors

    #mainContent p.productDescription em.priceTag { ... }
    

    Only adds value if you have

    p.productDescription em.priceTag { ... }
    

    Or

    em.priceTag { ... }
    

    In other places that you don’t want to affect – for example if you had a “#secondaryContent p.productDescription em.priceTag” that you didn’t want to apply the style to.

    So if you want to use

    em.priceTag
    

    And have the rule applied to all, you’ll actually see no performance issue (the difference would be about the same as the file-size difference you save anyhow by having less chars in the rule).

    HOWEVER… don’t pollute your HTML with tons of class=”” attributes just because you don’t want to write a proper rule.

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

Sidebar

Related Questions

I'm working on a small website for a local church. The site needs to
I am working on a small intranet site for a small company, where user
I am working on a small PHP website. I need a MySql database access
I'm currently working on a small CMS for my website and I'm getting following
I've been quite used to working on small projects which I coded with 1,000
I'm working on a small templating engine, and I'm using DOMDocument to parse the
I am working on a small application in VB.NET. The program needs administrator privilege
I'm working with a small FAT16 filesystem, and I want to generate CRC values
I'm working on a small app where I can generate a list of barcodes.
I'm working in a small company and weeks away from deploying a web-app that

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.