Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In web development, you often hear the terms "element" and "control". The term "element" is often associated with HTML, and you hear the term "control" most often in Asp.NET development... but the w3c refers to controls in the Forms in HTML documents recommendation, blurring the lines a little.

What is a control and what is an element? How are they the same and how are they different? Is one a generalization of the other?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

Element refers to DOM Elements. In other words, every part of the page is an element. Javascript/DHTML is all about manipulating these elements to make the page interactive.

A control, in the W3C sense, is a type of element that accepts user input. Things like textboxes, radio buttons, and submit buttons are all controls under this definition.

The ASP.Net definition of a control is different from the W3C version. In ASP.Net, a control is a template that takes data and formats it as HTML. So, for example, a GridView control takes the data that you give it and formats it as a <table>. A Label formats data as a <span>. ASP.Net controls allow you to work at a higher level of abstraction than the W3C DOM. You can work with Labels, GridViews and Repeaters, rather than having to work out the HTML generation yourself.

share|improve this answer
    
That would of been my answer too! –  webdad3 Mar 31 '11 at 14:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.