Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Property or Attribute?

Reply
Thread Tools

Property or Attribute?

 
 
Robert Mark Bram
Guest
Posts: n/a
 
      07-29-2003
Howdy all!

When do I call something a property and when do I call something an
attribute?

It has me a little confused at the moment!

Any advice would be most appreciated!

Rob



 
Reply With Quote
 
 
 
 
Robert Mark Bram
Guest
Posts: n/a
 
      07-29-2003
Howdy David!

> > When do I call something a property

>
> When its CSS.


So I can say that the visibility property can be set to visible or
invisible..

> > and when do I call something an attribute?

>
> When its HTML or XML.


And I can talk about the SELECTED attribute of a CHECK BOX..


What about in JavaScript? Should I say a SELECT element has OPTION child
elements or properties.. and is the selectedIndex of a SELECT be a property
or attribute when I am accessing them in JavaScript?

I guess I am also gettting confused between JavaScript objects (which I know
are a collection of properties) and objects in the DOM. Do we say that
either of these have attributes?

Thank you very much for your response!

Rob



 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      07-29-2003
"Robert Mark Bram" <(E-Mail Removed)> writes:

> When do I call something a property and when do I call something an
> attribute?


The traditional usage is (if I understand it correctly):

- Javascript objects have properties. In "obj.foo" or "obj['foo']",
"foo" is the name of the property. Some properties are functions and
are sometimes called "methods". That is the terminology used in, e.g.,
the ECMS262 specification.

- HTML tags have attributes. In "<body onload='init()'>", "onload='init()'"
is an attribute. We call "onload" the attribute name and "'init()'" is the
attribute value. That is the terminology used in the HTML specifications.

- CSS rules have properties. In "#foo {width:50px;color:red;}" the
(CSS) properties are "width" and "color". That is the terminology used
in the CSS specifications.


Where it becomes fun is when you write things like:
<div id="foo" style="color:red;">
and later
document.getElementById("foo").style.color="green" ;

- "document" is a global variable (a property of the global object),
and it refers to the document object.
- "getElementById" is a property of the document object. It is a function
so we call it a method.
- The name "foo" refers to the id attribute of the div tag, and the DOM
*element* (an object) returned by the function call is the DOM
representation of the div *tag*.
- The "style" property of the div element corresponds to the "style"
attribute of the div tag.
- the "color" property of the style element corresponds to the CSS property
"color".

/L
--
Lasse Reichstein Nielsen - http://www.velocityreviews.com/forums/(E-Mail Removed)
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
Robert Mark Bram
Guest
Posts: n/a
 
      07-29-2003
Thank you so much for the reply Lasse,

Your explanation clears up a lot of things for me - in particular the idea
that although each technology maintains its own lingo, they crossover
somewhat.

Thank you again.

Rob



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding to property of property of object collection TS ASP .Net 3 08-31-2006 12:57 PM
TableCell: BackColor Property But No BackGround Property? Nathan Sokalski ASP .Net 1 04-29-2006 10:09 PM
DataBinder.Eval for an object's property property... like Eval(Container.DataItem,"Version.Major") Eric Newton ASP .Net 3 04-04-2005 10:11 PM
Set CSS property equal to another CSS property? Noozer HTML 10 10-13-2004 09:20 PM
Is there a way to set the a CSS property to be explicitly the same as another CSS property? Joshua Beall HTML 1 12-10-2003 07:21 PM



Advertisments