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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:18:59+00:00 2026-06-14T19:18:59+00:00

CSS rules applied to IDs have higher priority than class rules, that makes sense.

  • 0

CSS rules applied to IDs have higher priority than class rules, that makes sense. What I don’t get is why this:

<div id="global_button" class="global_button_class"></div>

#global_button
{
   opacity:0.7;
}

.global_button_class:hover
{
   opacity:1;
}

…doesn’t change the opacity when the mouse is hovered over the button, but if I change from:

.global_button_class:hover

…to:

#global_button:hover

…it works. I mean, if the hover state isn’t defined by the id, why doesn’t .global_button_class:hover kick in?

  • 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-06-14T19:19:01+00:00Added an answer on June 14, 2026 at 7:19 pm

    Basically because you have set the opacity property using the elements ID it is setting the state for hover, focus, active etc on that too.

    When you try to set the hover state using the class name you have attached it gets overwridden by the previously stated ID which gets more weight than the class.

    ID > CLASS

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

Sidebar

Related Questions

I have an element with some CSS rules applied as follows: <span class=rule1 rule2
I have the following CSS rules applied to a DIV: .icon { position:relative; display:
I have defined a fieldset in HTML, and applied the following (simple) CSS rules
I have a registration form where this CSS rules apply. when user submits with
I have a table with the following CSS rules applied: table { border-collapse: collapse;
For example if I have the following HTML: <div class=someDiv></div> and this CSS: .opacity
I have two CSS rules following each other: .some td:first-child:before { content:url('path/to/image.png') ; }
W3 specifies that only four CSS rules are allowed for table columns (with the
I want to apply the rules in a CSS file to a certain div/class
I have a text element within an SVG that I have applied jQuery ui

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.