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.
Loading...
Related Quiz
- When defining a CSS variable within a specific element, how does its scope differ compared to when it's defined in :root?
- To create a layout that adapts to different screen sizes, developers use ________ queries in CSS.
- Which CSS property allows you to set a graphical element to be used as a mask against an element?
- In a flex container, setting flex-grow to a value of ________ will ensure the item grows to absorb any extra space.
- Which property allows you to control the size of tracks in a grid layout?