If two selectors apply to the same element but one contains an ID and the other a class, which one takes precedence?

  • Class Selector
  • ID Selector
  • The selector listed first
  • The selector listed last
In CSS, when two selectors apply to the same element, specificity is considered. An ID selector has a higher specificity than a class selector. Therefore, the selector with the ID takes precedence over the one with the class.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *