โš–๏ธattributes vs. properties

HTML attributes vs. DOM properties

๐Ÿ”ธ HTML attributes โ”Š DOM propertiesโ”Š attr-prop sync โ”Š

For element nodes, most standard HTML attributes automatically become properties of DOM objects. ๐Ÿ“— JS.info โŸฉ Attributes and properties

<body id="page"> => body.id="page"

HTML attributes

  • attribute name is case-insensitive.

  • attribute values are always strings.

  • element.attributes collection is iterable and has all the attributes as objects with name and value properties.

DOM properties

property โ‡” attribute sync

Last updated

Was this helpful?