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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:15:35+00:00 2026-05-18T03:15:35+00:00

I am not new to CSS, I’m just not that adept with it. I

  • 0

I am not new to CSS, I’m just not that adept with it. I ran into an ‘issue’ today in having a sub-element being overwritten by the parent’s css. After some head scratching I realized all I needed to do was add an ‘! important’ to the css (which to show you my ability is brand new to me)

(I have placed a working example @ that illustrates my question in living color)
http://jsfiddle.net/4RYM3/1/

#byIdName div{  /* #1 */
       margin: 30px;
    background:#FF00FF;
}
div#ByIdNameTwo{  /* #2 */
           margin: 30px;
     background:#00FF00;
}
div.idone{
    margin: 20px;
    background:#FFFF00;
}
div.idtwo{
    margin: 0px;
    background:#cccccc;
}
div.idone2{
    margin: 20px ! important;
    background:#FFFF00 ! important;
}
div.idtwo2{
    margin: 0px ! important;
    background:#cccccc ! important;
}

http://www.w3.org/TR/CSS2/cascade.html#specificity

Now looking at this, I cannot understand why #1 and #2 seem to behave differently (please look at the jsfiddle link above).
While I am happy that I got this to work (with the ! Important) I am lost as to the why #1 and #2 are behaving in the manner that they are.

Can anyone shed some light on this behavior?

Is one the preferred method and the other looked down upon, and if so why (this is my main question)?

thanks in advance

  • 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-18T03:15:35+00:00Added an answer on May 18, 2026 at 3:15 am

    These behave differently because #byIdName div refers to any children of type div with parent #byIdName

    This div#ByIdNameTwo refers to any div with ID #byIdNameTwo

    for Direct children use #byIdName>div

    for any children including grand-children great-grand-children….etc. use

    #byIdName div
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new with css, but was having an issue trying to accommodate all
Since i am new to CSS, i am not sure if the following page
I'm not exactly new to PHP but I haven't used MySQL that much, so
I'm not new at CSS, but this is problem for me and I can't
I am new at CSS and just wondering if it is possible to have
I'll start out by saying that I'm totally new to CSS and HTML so
I'm pretty new to CSS and have found a nuance that I don't understand.
I need a rule in Apache that redirects not-found CSS files to another location
I'm a novice, but not entirely new to CSS and coding. Over the last
I'm not new to HTML, CSS, JS or PHP, I already made diff. web

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.