Search⌘ K
AI Features

Scoped CSS

Explore how Angular applies scoped CSS to components, ensuring styles only affect their own templates. Understand how to use component-specific CSS files and the :host selector to style component host elements for better style encapsulation.

The application has everything it needs. The last thing we need to do is add some styles. We have the option of defining styles in the src/styles.css file. This is what we did in the last project.

There’s an alternative approach you may want to consider, which uses the component CSS. Every component comes with its CSS files. The app component has the app.component.css file, and the post component has the post.component.css file.

The main benefit of defining styles in the component CSS files is that the styles are ...