Thursday, 2 June 2016

Elements

Elements

If you are sitting at a coffee shop next to a table of Web developers, you will probably hear three words quite a bit:  'Tags', 'Attributes' and 'Elements' (or sometimes 'DOM elements', same thing just more precise and wordy).
'Elements' are the pieces themselves, i.e. a paragraph is an element, or a header is an element, even the body is an element.  Most elements can contain other elements, as the body element would contain header elements, paragraph elements, in fact pretty much all of the visible elements of the DOM.
Consider the figure above.  It contains a single <html> element.  It turns out this includes within it the entire content of your html file.  If you click on the "html" node, you'll find that it contains two components, a head and a body.  Clicking on each of those will reveal their respective contents.  This structure is what we computer scientists call a "tree".  Any given element (except for the outermost <html> element) is wholly contained inside another element, referred to as the "parent" element.  Not surprisingly, the elements that a given element contains are its "child" elements.  And, yes, children of a common parent are often referred to as "siblings".
Thus in the example above, the top element is the html element, which contains just two elements, the head and body.  The head element contains a title element and the body contains an <h1> element and a <p> element.  In a more typical example, the body would contain many more children, but for our purpose this is enough.
That may be a great picture, but how do we represent such a structure in a text file?  Well, that's where "tags" come in.

0 comments:

Post a Comment

Social Profiles

Twitter Facebook Google Plus LinkedIn RSS Feed Email Pinterest

Popular Posts

Total Pageviews

Powered by Blogger.

Followers

Featured Posts

Copyright © Learn IT Skills | Powered by Blogger
Design by Lizard Themes | Blogger Theme by Lasantha - PremiumBloggerTemplates.com