473,433 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,433 software developers and data experts.

Property or Attribute?

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
:)
Jul 20 '05 #1
3 2573
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
:)
Jul 20 '05 #2
"Robert Mark Bram" <re********@removethis.optushome.com.au> 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 - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
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
:)
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DraguVaso | last post by:
Hi, I'm having some weird behaviour, and I can't find any solution to this. I made a UserControl (uclCommands) which contains a Toolbar (ToolBar1) with Modifiers = Public. I put this...
18
by: Robin Becker | last post by:
Is there a way to override a data property in the instance? Do I need to create another class with the property changed? -- Robin Becker
5
by: David N | last post by:
All, I created a control that have the following property defined: private bool autoSearch My control is compiled and created fine. But, after adding the control to my form, I noticed...
6
by: Tom Kiefer | last post by:
Question: If I have an ASP.NET User Control which defines/exposes a property that the page can use to specify a mode or data subset for the control to use, is there a way to tell the @OutputCache...
11
by: Andrus | last post by:
I'm implementing entity object which should populate its properties from database when property is first referenced. In RDL reports I use object properties like MyObject.MyProperty MyObject...
3
by: Bob Cohen \(106531\) | last post by:
I want to define some metadata using custom attributes to apply to properties in various classes. The properties return values that are classes themselves. I want to retrieve the attribute...
8
by: Ethan Kennerly | last post by:
Hello, There are a lot of Python mailing lists. I hope this is an appropriate one for a question on properties. I am relatively inexperienced user of Python. I came to it to prototype...
0
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was...
14
by: Rafe | last post by:
Hi, I've encountered a problem which is making debugging less obvious than it should be. The @property decorator doesn't always raise exceptions. It seems like it is bound to the class but...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.