• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Basic (X)HTML Formatting

Chapter 4. Basic (X)HTML Formatting

While it’s a good idea to try to separate formatting from content and to use style sheets for controlling the appearance of your page, there are a few simple (and still legal) ways to format text in (X)HTML that I will discuss in this chapter.

Why should you use basic (X)HTML formatting instead of CSS? There are two main reasons. First, most of the elements discussed in this chapter are logical elements, that is, they give structure to your document by describing what they contain. For example, the code element is specifically designed for formatting lines of code from a script or program. While it formats such content in a monospace font, it also more importantly identifies the text as code.

The second reason to use the basic formatting elements in this chapter is because CSS is sometimes too big a bazooka for the job. If you want to highlight a word or phrase on your page, instead of enclosing it in a span element with a particular class and then creating a style sheet for that class, you can just wrap it in a simple formatting element and be done with it.

There are a number of formatting elements—for changing the font, size, and color, for example—that, while still legal and supported, are being phased out of (X)HTML in favor of style sheets. I discuss these (and the pros and cons of using them) in Chapter 21, Formatting: The Old Way.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint