Generic Containers (<DIV> and <SPAN>)
Up until now, we have stated that you should use HTML to add meaning to your
document's contents. What if you really want to just change the presentation of phrase or block without
changing its meaning? HTML 4.0 provides two generic containers that can be used for any purpose you so desire:
the <DIV> and <SPAN> elements.
Both of these elements have no default rendering or behavior. Instead, you can add any
presentation or behavior you require. The difference between the <DIV> and <SPAN> element is
the DIV element is a block element and creates line-breaks before and after itself, and the SPAN element
is a phrase element.
These two elements also temporarily fill the gap in HTML that XML will eventually fill. Many
times you want to add your own markup to a page. For example, you may want to define that a particular reference
to a name is the author of the document. Since there currently is no author element, and HTML prohibits you from
inventing one, you can wrap the author with a SPAN tag and associate a particular class or id with it:
<SPAN ID=author>Scott Isaacs</SPAN>
When deciding whether to use an ID or CLASS, you should look at whether more than one particular element
can exist in the document. If you can have multiple authors, you should use CLASS=author instead of the ID. This is because
a proper HTML 4.0 document must contain unique IDs. Giving two elements the same ID violates the HTML 4.0 specification. However
any number of elements can share the same CLASS, even different elements.
With the introduction of CSS Positioning the DIV and SPAN elements are also
commonly used to group contents that are to be positioned on the page. Again, positioning is
purely presentational and therefore is associated with an appropriate element using CSS. The HTML recommendation
no longer contains elements designed just for presentation.
Now you have seen the various ways you can markup and add meaning to your document using both inline and block elements.
Next we will discuss how you can author and relate multiple documents together using the <A> element plus a new more
efficient and powerful way to designate the destination for your links.
Navigation Elements...
|