Styling the components

Before diving into the depths of our Angular app, it might be the case to ask ourselves a quick question about what we just did in the style sheet file of QuizSearchComponent. Is there a reason why we put the search-header and search-navmenu classes there? Couldn't we place them in the AppComponent and NavMenuComponent LESS files to handle everything from the parents, thus leaving the child without a dedicated style sheet?

To properly answer such questions, we need to understand how Angular handles its components and their style sheet files; the best way to do that is to introduce a whole new concept called CSS Encapsulation, which will greatly help us in styling our components.

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.