Inline styles are CSS rules written directly inside the component's decorator using the styles array. They apply styles only to that component.
Click to reveal answer
beginner
How do external styles work in Angular components?
External styles are CSS files linked to a component using the styleUrls property in the component decorator. They keep styles separate from code and can be reused.
Click to reveal answer
intermediate
Name one advantage of using inline styles in Angular.
Inline styles keep the styles close to the component code, making it easier to see and change styles quickly for small or unique style rules.
Click to reveal answer
intermediate
What is a benefit of using external styles over inline styles in Angular?
External styles help keep the component code clean and allow sharing styles across multiple components, improving maintainability.
Click to reveal answer
advanced
Can Angular components use both inline and external styles together?
Yes, Angular components can use both styles and styleUrls together. Inline styles override external styles if there is a conflict.
Click to reveal answer
Where are inline styles defined in an Angular component?
AIn a separate CSS file linked with <code>styleUrls</code>
BInside the component's TypeScript class
CIn the global styles.css file
DInside the <code>styles</code> array in the component decorator
✗ Incorrect
Inline styles are defined inside the styles array directly in the component decorator.
What is the main purpose of using external styles in Angular?
ATo write styles inside the component's TypeScript code
BTo keep styles separate and reusable across components
CTo override inline styles automatically
DTo disable component styling
✗ Incorrect
External styles keep CSS separate from code and allow reuse across multiple components.
If a style is defined both inline and externally, which one takes precedence?
AExternal styles
BNeither, styles conflict and are ignored
CInline styles
DThe first one loaded by the browser
✗ Incorrect
Inline styles override external styles if there is a conflict.
Which Angular decorator property is used to link external CSS files?
AstyleUrls
BcssFiles
Cstyles
DexternalStyles
✗ Incorrect
The styleUrls property links external CSS files to the component.
Why might you choose inline styles for a component?
ATo keep styles close and simple for small changes
BTo share styles across many components
CTo improve global site styling
DTo disable CSS encapsulation
✗ Incorrect
Inline styles are good for quick, small style changes close to the component code.
Explain the difference between inline and external styles in Angular components.
Think about where the CSS code lives and how it affects the component.
You got /4 concepts.
Describe a scenario where you would prefer inline styles over external styles in Angular.
Consider ease of access and simplicity for small style rules.
You got /3 concepts.
Practice
(1/5)
1. In Angular, where do you place inline styles for a component?
easy
A. Inside the styleUrls array in the component decorator
B. In the global styles.css file
C. Inside the styles array in the component decorator