The HTML Standard has two words for this. A content attribute is what you write in markup: a name and a string value stored on the element, read with getAttribute() and written with setAttribute(). An IDL attribute is a property defined on the element's interface, such as input.maxLength, implemented as a getter and setter.
Most IDL attributes reflect a content attribute: the getter reads the attribute and converts it, the setter writes a string back. The conversion depends on the property's type:
- String: returned as is; a missing attribute reads as
"", notnull. - URL (
a.href,img.src): parsed against the document's base URL and returned absolute. - Boolean (
disabled,hidden):truewhen the attribute is present at all. Settingtruewrites"";falseremoves it. - Number (
maxLength,tabIndex): parsed; an invalid or missing value returns a default (-1formaxLength). - Enumerated, limited to known values (
input.type): an unknown keyword returns the default state's keyword.
Some names differ because they clash with JavaScript: class is className, for is htmlFor. A made-up attribute such as foo gets no property at all.
Form controls break the mirror. For <input>, the value attribute is only the default value, reflected by defaultValue. The value property is the current value. Once the user edits the field or a script sets value, the control's dirty value flag is set and later attribute changes no longer reach it. checked and defaultChecked work the same way with a dirty checkedness flag. That's why form reset (back to the attributes) is possible, and why setAttribute('value', …) often seems to do nothing.
Rule of thumb: use properties for state and typed values; use attributes for what's serialised, for CSS attribute selectors, and for names with no property.