views:

174

answers:

3

Can anyone give me deatails on each?

for example?

Is #ID an attribute or property or selector or anchor?

Is default property and default attributes are different thing?

Are all these Tags or elements?

What we will say to this

<img src="angry.gif" alt="Angry face" title="Angry face" />

This

<div>.....</div>

and these

<br /> , <hr />

Syntax , Tag or elements?

Thanks in advance.

+5  A: 

In:

#menu ul li {
  display: inline;
}

we have:

  • Selector: #menu ul li;
  • Property: display;
  • Property value: inline.

In:

<ul id="menu">...</ul>

we have:

  • Element or Tag: <ul>;
  • Attribute: id;
  • Attribute value: menu.

Edit: Ok, to address this issue of tags vs elements.

Both the XML and HTML 4.01 specifications use the terms:

  • Start Tag: <ul>;
  • End Tag: </ul>; and
  • Element <ul>...</ul>.

However, in colloquial usage, such distinctions are so rare that there are arguments about it. In normal use the terms are interchangeable even though that it not their precise definition.

cletus
is Element and Tag is same thing?
metal-gear-solid
@Jitendra - technically, an *element* is a tag that has been rendered on the page and exists in DOM
K Prime
@K Prime - The term element is not, as I understand it, exclusive to DOM. Elements are also part of XML before being rendered. In fact, I think `node` is the preferred term once something is rendered in the DOM (oh it is all too confusing, Jitendra's right!)
Anthony
@Anthony: The term DOM is not exclusive to HTML. DOM is also part of XML. So K Prime is correct.
slebetman
`<foo>…</foo>` is an element declaration and `<foo>` and `</foo>` are its opening and closing tags respectively.
Gumbo
@cletus - ok ur explanation about TAG vs elements but what will say to <img> <a> , and <br />, <hr /> etc? And what is the means of syntax?
metal-gear-solid
+1  A: 

You are basically asking about context.

Attribute

An id, in the context of an element, is an attribute. This is true both for XML and DOM context. So when I say "What is that element's ID?" I'm referring to the element's id attribute.

Selector

If I am using an attribute to add style to the document, I'm using a selector. A selector is the way in which I select the thing (whether it is an element or an attribute) that I want to apply the style rule to.

Tag,

and I'm still fuzzy on this, refers either to the actual type of element, or the literal bit of code itself. So I can say "You forgot to close that div element" or I can say "you need a closer tag on that div". So a tag is what designates what the element in question is.

The element

itself is, most loosely, the opening tag, the closing tag (in any) and the text in between (if any). But more strictly, it is also any attributes of that element. The attributes may change (perhaps you use a script to swap out where an img element's src points) and that doesn't make it a different element, but the element still has that attribute and thus it is part of the element, even if only for a short time.

Properties

are an aspect of Object-Oriented programming. In the context of Javascript, a property could be part of an object that never gets output at all to the user or inserted into the HTML. You may have a special class in your script for converting data that the user enters. Once you get the property of the object, you then might run it through some other function before finally outputting back to the user. The reason you may hear of properties in terms of HTML is because of how Javascript interacts with the document as a "Document Object Model" (DOM). If you define a variable as "document.getElementById("blah"), that variable is now holding an object, and various properties in that object will coorespond to various aspects of that element, some of which may be pre-defined attributes, such as the border color or value, and other things not defined at the HTML level, such as it's position on the screen or rendered font height.

Anthony
i added more info to question
metal-gear-solid