5 What about formatting?

Sometimes, the content of a document does call for special formatting for emphasis and other effects. The most appropriate method to handle this is to use cascading stylesheet specifications and references either by class or id.

Any element in HTML can possess a class and/or id attributes. Any number of elements in an HTML document may share the same value for their class attributes. However, the ID attribute of an element must be unique amongst all elements in the document.

At the block level, the <div> element is commonly used to specify class or id attributes. In other words, the div element is useful as a container to hold contents that should be displayed in a certain way.

To specify a selection of inline text for formatting purposes, you can use the <span> element.

Note that it is important to focus on how a selection of text is important, rather than what it should look like. For instance, If one is writing a technical manual, there may be different blocks of text that are important. Some blocks may require attention because they serve as warnings. Other blocks may be important because they contain extra information for a particular topic.

A good approach is to define two classes, one called warning, and the other called moreInfo. Then, use <div> elements to contain these two types of blocks. If the classes do not have any specifications in CSS, then the associated blocks will simply be displayed as regular text. However, in order to make these blocks look special, all it takes is a CSS specification.