Suggest an editImprove this articleRefine the answer for “How are directives related to DOM elements?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)In Angular, directives are **bound to DOM elements** through a selector: 1. When Angular renders a template, it **looks for elements matching the directives' selectors**. 2. Angular then **creates an instance of the directive** and links it to that element. 3. The directive can **change the element's properties, styles, classes and attributes**, listen for events or control its structure (for structural directives). 4. `ElementRef` and `Renderer2` are often used to interact with the element and safely modify the DOM.Shown above the full answer for quick recall.Answer (EN)ImageIn Angular, directives are **bound to DOM elements** through a selector: 1. When Angular renders a template, it **looks for elements matching the directives' selectors**. 2. Angular then **creates an instance of the directive** and links it to that element. 3. The directive can **change the element's properties, styles, classes and attributes**, listen for events or control its structure (for structural directives). 4. `ElementRef` and `Renderer2` are often used to interact with the element and safely modify the DOM. Example: ```html <p appHighlight>Text</p> ``` - The `appHighlight` directive is bound to `<p>`. - Its constructor can use `ElementRef` to change the background, color, class and so on. > Conclusion: directives are "wrappers" around DOM elements that let Angular control their behavior and appearance.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.