Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is inline CSS?
Inline CSS is CSS code written directly inside an HTML element using the style attribute. It applies styles only to that specific element.
Click to reveal answer
beginner
What is external CSS?
External CSS is CSS code written in a separate file with a .css extension. This file is linked to the HTML document using the <link> tag inside the <head> section.
Click to reveal answer
beginner
Which has higher precedence: inline CSS or external CSS?
Inline CSS has higher precedence than external CSS. This means if both define a style for the same element and property, the inline style will be applied.
Click to reveal answer
intermediate
Why does inline CSS have higher precedence than external CSS?
Inline CSS is considered more specific because it targets a single element directly. Browsers apply the most specific style rule, so inline styles override external styles.
Click to reveal answer
intermediate
How can you override inline CSS if needed?
You can override inline CSS by using !important in external or internal CSS, or by using JavaScript to change styles dynamically.
Click to reveal answer
Which CSS style will apply if both inline and external CSS set the same property on an element?
AInline CSS
BExternal CSS
CBoth apply equally
DNeither applies
✗ Incorrect
Inline CSS has higher precedence and will override external CSS for the same property on the same element.
Where is external CSS usually linked in an HTML document?
AInside the <footer> tag
BInside the <body> tag
CInside the <head> tag
DInside the <nav> tag
✗ Incorrect
External CSS files are linked inside the section using the tag.
What attribute is used to add inline CSS to an HTML element?
Aclass
Bstyle
Cid
Dcss
✗ Incorrect
The style attribute is used to add inline CSS directly to an HTML element.
Which method can override inline CSS styles?
AUsing external CSS without !important
BUsing inline JavaScript alerts
CUsing only HTML attributes
DUsing !important in external CSS
✗ Incorrect
Using !important in external CSS can override inline styles because it increases the rule's priority.
Why is inline CSS generally discouraged for large projects?
AIt makes code harder to maintain and reuse
BIt is slower to load
CIt does not work in modern browsers
DIt cannot style text
✗ Incorrect
Inline CSS mixes content and style, making code harder to maintain and reuse compared to external CSS.
Explain the difference between inline and external CSS and which one takes precedence.
Think about where the CSS code is written and how browsers decide which style to apply.
You got /3 concepts.
Describe how you can override an inline CSS style using external CSS.
Consider CSS specificity and special keywords.
You got /3 concepts.
Practice
(1/5)
1. Which CSS style has the highest priority when applied to the same HTML element and property? style="color: red;" vs external stylesheet setting color: blue;
easy
A. Both have equal priority
B. External CSS file
C. Inline CSS inside the style attribute
D. Depends on the order of CSS files
Solution
Step 1: Understand CSS specificity rules
Inline CSS (style attribute) has higher specificity than external CSS selectors.
Step 2: Compare inline and external styles on the same property
When both define the same property, inline CSS overrides external CSS.
Final Answer:
Inline CSS inside the style attribute -> Option C
Quick Check:
Inline CSS > External CSS [OK]
Hint: Inline styles override external styles for same property [OK]
Common Mistakes:
Thinking external CSS always overrides inline
Confusing order of CSS files with inline priority
Assuming equal priority for inline and external
2. Which of the following is the correct syntax to add inline CSS to an HTML element?
easy
A.
Text
B.
Text
C.
Text
D.
Text
Solution
Step 1: Recall inline CSS syntax
Inline CSS uses the style attribute with CSS rules inside quotes.
Step 2: Check each option for correct attribute and format
Only
Text uses style="color: blue;" correctly.
Final Answer:
<div style="color: blue;">Text</div> -> Option A
Quick Check:
Inline CSS uses style attribute [OK]
Hint: Use style="property: value;" for inline CSS [OK]
Common Mistakes:
Using class or css attribute instead of style
Missing quotes around CSS rules
Using invalid attribute names
3. Given the HTML and CSS below, what color will the text inside the <p> tag be?
<style>
p { color: green; }
</style>
<p style="color: orange;">Hello</p>