Tutorial :what's the difference between Element and Element ID?


what's the difference between Element and Element ID?


<div id="element-id"></div>  

The element is div, the element's ID is element-id.

Note that every ID should be unique in the DOM tree.


In the DOM, an Element is what you would call a "tag" in HTML-speak, for example <a id="myanchor">Hello world!</a>. That Element's ID is myanchor.

This answers the question, but I'm not sure if it's what you wanted to know... and it has nothing to do with css-layout.


CSS has many selectors:

a           { color: red; }    - all hyperlinks  #firstname  { color: red; }    - any html object with id: firstname  .firstname  { color: red; }    - any html object with class: firstname  

For more info: http://www.w3.org/TR/CSS2/selector.html

The element is the actual HTML element (tag).
The element's ID is the HTML element's id attribute.


Element { border: 1px solid red; } This will affect all elements form this type

Element#ID{ border: 1px solid red; } Will affect the element with this ID only if it is form the spcified type (Element)


div{ color: red; } All inputs will have red text

div#my_input{ color: red; } my_input will have red text only if it is a DIV

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »