Attributes and properties are fundamentally different things. You can have an attribute and property of the same name set to different values. For example: <div foo="bar">…</div> <script> const div = document.querySelector('div[foo=bar]'); console.log(div.getAttribute('foo')); // 'bar' console.log(div.foo); // undefined div.foo = 'hello world'; console.log(div.getAttribute('foo')); // 'bar' consol
![HTML attributes vs DOM properties](https://cdn-ak-scissors.b.st-hatena.com/image/square/ebff5ed0d1e05b3301cbf043cfe32b9657a0d3c7/height=288;version=1;width=512/https%3A%2F%2Fjakearchibald.com%2Fc%2Fimg-0ddc5222.png)