Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Values css _nghost-c0 in angular

I'm learning Angular 5 and I see the html tags with the ng generated attributes: _nghost-c0, _nghost-c1...

What does it mean?

[_nghost-c3] .employees[_ngcontent-c3] button[_ngcontent-c3] {
 color: #681f32;
}
like image 422
ararb78 Avatar asked Aug 25 '26 01:08

ararb78


1 Answers

This is called Emulated Shadow DOM. These are attributes that angular uses to isolate component styles from one another.

To explain, let app.component.html like this

<header>
  <span>from App Component</span>
</header>

<app-alert></app-alert>

app.component.css

header span {
    color: red;
}

In alert.component.html

<header>
    <span>from alert component</span>
</header>

alert.component.css

header span {
    color: blue;
}

enter image description here

for more: https://dev.to/themeticulist/everything-you-should-know-about-styles-in-angular-12ab

like image 67
Sanka Sanjeewa Avatar answered Aug 28 '26 02:08

Sanka Sanjeewa