These seem to mean the same thing. But what term is more appropriate in what context?
-
4Can you be more specific about the context? For example the terms mean utterly different things within a C# context. – David Arno Nov 03 '08 at 12:20
-
1@David Arno - different language syntaxes have appropriated one or both words but independent of a particular language's syntax, is there a difference in the meaning? It's not a bad question. – Corey Trager Nov 03 '08 at 12:26
-
4I think it is a bad question. A check of a thesaurus will show that they are synonymous in real language terms, but different computer and meta languages may assign them quite different roles and thus they may not be synonymous for a particular computer language. So context is everything. – David Arno Nov 03 '08 at 12:30
-
14I'm more.... sympathetic. I remember the first time I heard the term "method". What the heck is a "method"? Oh, it's what you call a function when it belongs to a class. Why new terminology for something old? Thoreau said, "beware of all enterprises that require new clothes". (or words...) – Corey Trager Nov 03 '08 at 12:52
-
1Yep, totally depends on the context, but this is an excellent question! In mathematical terms a function returns a value ('for a given X, there can be only one Y,' usw.). A method just 'does something.' In XML (for example), an attribute has a `name` property and a `value` property. Properties are generally abstract, while attributes are generally concrete (think class/object). Humans have properties: `hasHair` and `hairColor`. "John" has attributes: `hasHair="true"` and `hairColor="purple"` (John is a *Twisted Sister* fan). – nothingisnecessary Aug 09 '13 at 21:45
-
1This question is too broad without providing some context (as written it can only really be answered with a list of all possible contexts). – Quentin Mar 22 '14 at 09:09
-
I looked here with same question. I am doing a system where I am juggling what to all a "Typed[xx]Map" ie: TypedPropertyMap vs TypedAttributeMap as a container for dymamic fields - seems like it doesn't matter - Maybe TypedObjectMap as a base class because inside a computer they are all just strings of bits :) – peterk Oct 01 '14 at 16:12
-
well i can't answer any more but a property is something you have. It's tangible an attribute is something that is. You are 6 ft property. You are tall Attribute. You have eyes properties, Your eyes are green Attributes. Your eyes can have certain properties that make it red tho. You have pants property. You can run fast Attribute. Roses smell good Atrribute. The pollen or whatever makes it smell go are Properties. These properties give rise to these attributes. because of my long legs (property), i run fast (attribute).
-
we use property in a generic and ordinary sense as a synonym for feature or “characteristic.” If multiple values are possible, the property is called an attribute, “dimension,” or “variable.” – Ahmad Ismail Aug 16 '21 at 09:25
-
This question should not have been closed. To provide "more clarity and details" to the question is tantamount to providing education on data modeling to the people who closed the question. Please be knowledgeable of the subject and read the tags before closing questions. – Blessed Geek Aug 22 '23 at 05:04
-
Answers provided are quite apparently from the nutshell of html/Javascript programmers unfamiliar with Java and data modeling. – Blessed Geek Aug 22 '23 at 05:09
11 Answers
In general terms (and in normal English usage) the terms mean the same thing.
In the specific context of HTML / Javascript the terms get confused because the HTML representation of a DOM element has attributes (that being the term used in XML for the key/value pairs contained within a tag) but when represented as a JavaScript object those attributes appear as object properties.
To further confuse things, changes to the properties will typically update the attributes.
For example, changing the element.href
property will update the href
attribute on the element, and that'll be reflected in a call to element.getAttribute('href')
.
However if you subsequently read that property, it will have been normalised to an absolute URL, even though the attribute might be a relative URL!

- 334,560
- 70
- 407
- 495
-
5@RubensMariuzzo, however accurate it may be, there is no answer here.. it just elaborates on a possible point of confusion for people, given a context. – Brett Caswell Dec 02 '14 at 23:02
-
@BrettCaswell, I think in a DOM context (HTML/JS) this answer explains the difference clearly and simply to me. – Rubens Mariuzzo Dec 03 '14 at 23:28
-
1
-
I come from `python`. Can I use term `class attribute` and `instance property`? – joe Sep 19 '17 at 07:25
-
DOM stores all the HTML Tags and Attributes in the form of object in DOM modal, each attribute has its own values. When DOM Converts this HTML elements and attributes in object, then each object is created with its own property. So Updating any Property of object in DOM will update that attribute value in HTML. Check hear how both attribute and property behaves differently https://codepen.io/VijayDhanvai/pen/jzOpJB?editors=1011 – Vijay Dhanvai Mar 09 '18 at 06:41
-
Attributes: are those whose when making changes in DOM not have any change in its HTML. Attributes are scope free, like value, title etc. Property: are those whose when making changes in DOM then have change reflect in its HTML tres as well. Property has its own scope within element, like type in input tag. – Vijay Dhanvai Mar 09 '18 at 06:42
-
Please read the tags. The question is about data modeling and nothing to do with HTML or Javascript. – Blessed Geek Aug 22 '23 at 05:14
These words existed way before Computer Science came around.
Attribute is a quality or object that we attribute to someone or something. For example, the scepter is an attribute of power and statehood.
Property is a quality that exists without any attribution. For example, clay has adhesive qualities; i.e, a property of clay is its adhesive quality. Another example: one of the properties of metals is electrical conductivity. Properties demonstrate themselves through physical phenomena without the need to attribute them to someone or something. By the same token, saying that someone has masculine attributes is self-evident. In effect, you could say that a property is owned by someone or something.
To be fair though, in Computer Science these two words, at least for the most part, can be used interchangeably - but then again programmers usually don't hold degrees in English Literature and do not write or care much about grammar books :).
-
1You're closer to the meaning as I understand it to be. An attribute is a Type Describer, it describes the object to something out-of-context (like an interpeter).. that is, there is a context, but that context may very well be interchangable. To use HTML for example, the entire purpose of width holds no function if your parse the document without any intention to display/render it to a page. – Brett Caswell Dec 02 '14 at 23:36
-
Thank you! I came here looking for guidance on when to use which term when naming. I don't even care (much) if this is technically right or not, it's a really useful distinction. – user1433150 Feb 23 '16 at 01:20
-
1This is the type of answer I was looking for too. Why does context or what any particular language implementer decided matter. They may have made an arbitrary or uneducated decision. I want to make an educated one and this gives me concrete reasons to pick one over the other. It may also clarify why a particular implementer made their choice. – bielawski Mar 01 '16 at 12:57
-
2What works for me is to consider properties as objective and attributes as relative/subjective. Features like color, shape, score, wind speed, temperature (98'F) and other objective or measurable facts make good Properties. Features like texture ("soft"), conditions ("windy"), temperature ("hot") and other statements that are not undeniably true make for better Attributes. – Ivan Jul 04 '19 at 23:40
-
An attribute is the actual thing that you use within your HTML tag like
<input type="checkbox" checked="checked" />
In this instance type and checked are attributes. The property though is the value of these attributes, which the browser saves inside the DOM element. Often the value of the attributes and the properties are equal, that's what makes it so confusing.
In this example the DOM element input
has the property type
with the value "checkbox"
and the property checked
with the value true
(notice how this value differs from the value inside the HTML attribute).
Using Firebug you can observe the behaviour of properties when clicking on an element and selecting the "DOM view".

- 4,440
- 2
- 23
- 29

- 766
- 7
- 11
-
This could be the accepted answer. It is both clear in theory and useful in context. – Jaune Mar 25 '19 at 10:42
Often an attribute is used to describe the mechanism or real-world thing.
A property is used to describe the model.
For instance, a document (sitting on your desk) may have the attribute that it is a draft.
The class that models documents has a property to indicate whether or not it's a draft. In this case the property captures the state.

- 2,562
- 4
- 24
- 37
-
1
-
Intriguing, but I don't believe so. Given a document, an instance of an attribute might be a piece of paper; an instance of the model's representing property might be a buffer large enough to the contents of said paper. – Walt Stoneburner Aug 08 '15 at 12:51
The precise meaning of these terms is going to depend a lot on what language/system/universe you are talking about.
In HTML/XML, an attribute is the part of a tag with an equals sign and a value, and property doesn't mean anything, for example.
So we need more information about what domain you're discussing.

- 364,293
- 75
- 561
- 662
In Python...
class X( object ):
def __init__( self ):
self.attribute
def getAttr( self ):
return self.attribute
def setAttr( self, value ):
self.attribute= value
property_name= property( getAttr, setAttr )
A property is a single attribute-like name that wraps a collection of setter, getter (and deleter) functions.
An attribute is usually a single object within another object.
Having said that, however, Python gives you methods like __getattr__
which allow you extend the definition of "attribute".
Bottom Line - they're almost synonymous. Python makes a technical distinction in how they're implemented.

- 384,516
- 81
- 508
- 779
What is the difference between Attribute and Property?
What is the difference between Feature and Function?
What is the difference between Characteristic and Character?
What is the difference between Act and Behavior?
Its just a change in context.
Object,Product,Personality,Person
A Person Acts in a Behavior. A Personality has Characteristics of a given Character. A Product has Feature that derive Functionality. An Object had Attributes that give it Properties.

- 111
- 1
- 1
<property attribute="attributeValue">proopertyValue</property>
would be one way to look at it.
In C#
[Attribute]
public class Entity
{
private int Property{get; set;};

- 20,469
- 14
- 82
- 108
-
9Sorry to vote this down but in XML what you labeled a property is actualy an "element" – Harald Scheirich Nov 03 '08 at 13:48
-
@HaraldScheirich a slow reply ;) but the element is indeed called "property" to make clear the connection with the Entity.Property. It is not usual for xml elements to actually be called "element" – dove Dec 11 '17 at 09:14
In HTML it seems attributes are specific to the DOM tree while properties are used to describe the characteristics of DOM elements

- 1,668
- 25
- 27
In Java (or other languages), using Property/Attribute depends on usage:
Property used when value doesn't change very often (usually used at startup or for environment variable)
Attributes is a value (object child) of an Element (object) which can change very often/all the time and be or not persistent

- 21
- 1
Delphi used properties and they have found their way into .NET (because it has the same architect).
In Delphi they are often used in combination with runtime type information such that the integrated property editor can be used to set the property in designtime.
Properties are not always related to fields. They can be functions that possible have side effects (but of course that is very bad design).

- 52,876
- 38
- 145
- 202
-
Not necessarily. Automated dirty checking on a persistent object would be an example of a property with side effects that wouldn't be bad design. – Quibblesome Nov 03 '08 at 12:44