Zico Deng
Zico Deng

Reputation: 735

CSS type selector overrides attribute selector?

Generally speaking, an attribute selector has higher specificity than a type selector, but in the image below, the type selector wins (margin is set to 0)?

Is it because user agent stylesheet (browser default style) always gets overridden by custom CSS regardless of CSS specificity?

enter image description here

Upvotes: 1

Views: 279

Answers (1)

BoltClock
BoltClock

Reputation: 723448

Is it because user agent stylesheet (browser default style) always gets overridden by custom CSS regardless of CSS specificity?

Yes. The technical name for "custom CSS" is author-level CSS as detailed in this section of the spec. Specificity is only relevant when you're comparing two CSS rules that have the same origin, either two UA styles or two author styles.

Upvotes: 1

Related Questions