Attributes and properties are fundamentally different things. You can have an attribute and property of the same name set to different values. For exa

HTML attributes vs DOM properties

submited by
Style Pass
2024-04-24 12:30:04

Attributes and properties are fundamentally different things. You can have an attribute and property of the same name set to different values. For example:

If you do the above in a framework's templating language, you're using attribute-like syntax, but under the hood it'll sometimes be setting the property instead, and when it does that differs from framework to framework. In some cases, it'll set a property and an attribute as a side-effect, but that isn't the framework's fault.

Most of the time, these distinctions don't matter. I think it's good that developers can have a long and happy career without caring about the differences between properties and attributes. But, if you need to dig down into the DOM at a lower level, it helps to know. Even if you feel you know the difference, maybe I'll touch on a couple of details you hadn't considered. So let's dig in…

So when you're looking at the elements panel in browser developer tools, you're only seeing attributes on elements, not properties.

Leave a Comment