Bird
0
0

Which of the following is the correct syntax to add external styles in an Angular component?

easy📝 Syntax Q12 of 15
Angular - Components
Which of the following is the correct syntax to add external styles in an Angular component?
A<code>@Component({ styleUrl: ['app.component.css'] })</code>
B<code>@Component({ styleUrls: ['app.component.css'] })</code>
C<code>@Component({ styles: ['app.component.css'] })</code>
D<code>@Component({ styleSheets: ['app.component.css'] })</code>
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct property name for external styles

    The correct property is styleUrls (plural, camelCase) to link external CSS files.
  2. Step 2: Check syntax correctness

    The value must be an array of strings with file paths, e.g., ['app.component.css'].
  3. Final Answer:

    @Component({ styleUrls: ['app.component.css'] }) -> Option B
  4. Quick Check:

    External styles use styleUrls array [OK]
Quick Trick: Use styleUrls with array of CSS files for external styles [OK]
Common Mistakes:
  • Using singular styleUrl instead of styleUrls
  • Putting file names inside styles instead of styleUrls
  • Using wrong property names like styleSheets

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes