adspace
Answer Posted / A. Vinoth Saravanan
In Angular 2, you can define CSS using the `styles` property for inline styles or the `styleUrls` property for external stylesheets. To use them, follow these steps:
1. Declare the component and add the styles or styleUrls:
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `<h1>Hello World!</h1>`,
styles: [`h1 { color: red; }`],
styleUrls: ['styles.css']
})
export class AppComponent {}
```
2. Create the external CSS file (styles.css) and define your styles there.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Give the example of angularjs strings?
How to enable html5 mode in angular 1.x?
What is a dynamic route in angularjs and how do you implement it?
What is the latest angular?
How an object or function can get a hold of its dependencies?
How to implement a datagrid table with angular 2 and primeng?
What is the latest version of angular?
Which version you are using js?
How to create angularjs filter which outputs html?
How to use primeng in angular 4?
How can primeng be used with angular2?
How to get and log an error in angular 4?
Angularjs dependency injection of value inside of the module.config?