HTML attribute vs DOM property

Asked on November 14, 2016

What is difference between HTML attribute vs. DOM property?

Replied on November 14, 2016

Find some differences between  HTML attribute and DOM property

1. Attributes are defined by HTML and properties are defined by DOM.

2. The responsibility of HTML attributes is just to initialize DOM properties.  And then later DOM properties can change but HTML attributes cannot. 

3. There are some HTML attributes that have corresponding DOM property  and those DOM properties have corresponding HTML attributes such as id.

4.  There are also some HTML attributes that do not have corresponding DOM property such as colspan.

5. There are also some DOM properties that do not have corresponding HTML attributes such as textContent.

6.  The HTML attribute value contains initial value where as DOM property value contains current value.

Write Answer

©2024 | Privacy Policy | Contact Us