Publishers of technology books, eBooks, and videos for creative people

Home > Articles

This chapter is from the book

Marking Up Code

There are also two HTML tags specifically used for marking up code:

  • <code> is displayed in a monospace font and is used to represent a short snippet of computer code.

  • <pre> is also displayed in a monospace font and represents preformatted text. That means any text, including white spaces, appears exactly as it was typed.

If you need to display multiple lines of code, place the <code> element inside a <pre> element. The only time you should use <code> by itself is for an inline element (CODE 4.2, FIGURE 4.7).

FIGURE 4.7

FIGURE 4.7 Code 4.2 as rendered in Chrome.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.