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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:49:09+00:00 2026-05-11T19:49:09+00:00

I am having a problem trying to find any specific details on how to

  • 0

I am having a problem trying to find any specific details on how to properly write CSS rules in a stylesheet where the class or ID is nested within many other IDs and styles, e.g.

.mainbody #container #header #toprightsearch .searchbox {}

So here we have a searchbox class within a toprightsearch ID, in a header ID, in a container ID, in a mainbody class.

But it appears to work properly if I omit some of the IDs.

What is the correct way of listing these?
If I include all of the parents does it make it more specific?
Can it error on different browsers if I don’t include all?

And any additional information on this topic would be appreciated.

Thanks

  • 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-11T19:49:09+00:00Added an answer on May 11, 2026 at 7:49 pm

    If you include more parents, it does increase selector specificity. You shouldn’t have cross-browser problems omitting parents.

    There is no correct number of parents to list; it depends on what you require for your markup. As you’re seeing, selector1 selector2 means a selector2 at any level inside a selector1, and you can tune that for whatever behavior you need.

    In your example, you should list .mainbody #container #header #toprightsearch .searchbox if what you mean is for the style to only apply to .searchboxes that are inside that entire hierarchy. If contrariwise you want .searchboxes that exist other under conditions to get the same style, you should be less restrictive in the hierarchy. It’s only about what you’re trying to accomplish.

    Re comment: IDs produce more specificity, so omitting them reduces your rule’s specificity more.

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

Sidebar

Related Questions

I'm trying to find an answer for a problem my developers are having. I
I'm having a problem with trying to find out whether the parent element does
Having a problem trying to create a function, as part of a BizTalk helper
I am trying to convert this test code to C# and having a problem
I'm having a problem using the java.text.MessageFormat object. I'm trying to create SQL insert
I have been trying to tackle this problem , but I am having difficulty
I'm trying to do some basic paging in MSSQL. The problem I'm having is
Ok, so here's the full description of the problem I'm having: I am trying
I'm having a problem with CSS not displaying correctly between IE and Firefox... The
I'm having some problems trying to figure out how to solve a problem without

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.