Order of precedence
Brainteasers / Quiz
(2)
Here is another combination that has not been mentioned yet.
Imagine this:
- serif font-family in a linked style sheet for the paragraphs.
- sans-serif font-family in an imported style sheet for the paragraphs.
- monospace font-family as a document level style for the paragraphs.
Which one will take precedence? Which one will be applied to the paragraphs in the document?
Choose an answer:
[Explanation]
Explanation
The import command must come first within the document level style tags.
Any document levels style must come after it.
<style type="text/css">
@import url(myImportedStyles.css);
p { font-family: monospace; }
</style>
So the document level style is lower in the cascade than the imported style sheet.
- The style at the lower level in the cascade will take precedence if it conflicts with any styles at the upper levels for the same element.
The document level style for the paragraphs will take precedence instead of the styles in the imported style sheet and the linked style sheet for the paragraphs.
Help
Review: