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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:05:52+00:00 2026-05-22T19:05:52+00:00

When rendering web pages and applying styles, do browsers index ID’s and class names

  • 0

When rendering web pages and applying styles, do browsers index ID’s and class names for efficient search, or does it traverse the entire DOM from the top each time an ID or class name is specified to reach the correct element.

I’m wondering for optimisation reasons, and whether it’s worth giving the browser hints (longer selectors) to where an object of a certain ID is. I.e.

#container #one-of-many-container-siblings #my-id 

instead of:

#my-id

Will the former yield better performance if the DOM is quite large?

  • 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-22T19:05:53+00:00Added an answer on May 22, 2026 at 7:05 pm

    It actually works the opposite way to what you’re thinking.

    Remember that browsers parse CSS selectors right to left.

    This:

    #container #one-of-many-container-siblings #my-id
    

    will take more steps to match than this:

    #my-id
    

    See: http://www.css-101.org/descendant-selector/go_fetch_yourself.php

    Considering the question you’ve just asked, I recommend you read this article:

    http://css-tricks.com/efficiently-rendering-css/

    It will help you write more efficient selectors:

    #main-navigation {   }      /* ID (Fastest) */
    body.home #page-wrap {   }  /* ID */
    .main-navigation {   }      /* Class */
    ul li a.current {   }       /* Class *
    ul {   }                    /* Tag */
    ul li a {  }                /* Tag */
    * {   }                     /* Universal (Slowest) */
    #content [title='home']     /* Universal */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our iOS app has a Web View that is rendering pages from file: URLs.
HTML5 defines a standard algorithm for rendering web pages, and this algorithm specifies how
I am developing an ASP.Net web application. Some of my users' browsers are rendering
I have a Webforms, AJAX-enabled web page which, when rendering large amounts of data,
I'm having major rendering issues in Safari with the web application I'm working on.
I'm working with a Web Application and it's currently rendering in Quirks Mode. My
I have been experimenting with WPF and rendering strict XAML markup in a web
I have developed a web site and used update panel controls on all pages.
Since switching to Windows 7, we've noticed that several of our web pages have
Does anyone know of any embeddable Software/libraries for android/ios/etc that will provide web server

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.