Angular · Junior · Question 56 of 75

How do you set an inline style with a unit, e.g. width in pixels?

<div [style.width.px]="size"></div>

Explanation

Style bindings support units like .px, .% and .em. A null value removes the style.

Further reading

Problem with a question

Angular · Junior · question 56

Test yourself

Take the Angular · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz