HTML Pre Tag

The HTML pre tags are used to define the HTML pre element. The HTML pre element begins with the HTML <pre> tag and ends with the HTML </pre> tag. The HTML pre element is used to direct the browser to display a section of text exactly as it is typed with spaces and line feeds included.

HTML Pre Element Attributes

HTML "pre" element attributes include:

  • width - (Depreciated). The "width" attribute specifies the number of characters across the screen to display. This is very rarely used. An example of its use is <blockquote width="20">
  • class - The class attribute is used in conjunction with style sheets to associate an element with a class. The class attribute can set a class for specific element types or it can be independent of element types and work for all elements. The class attribute will provide the settings for specific style formatting. CSS properties are shown at the CSS Properties page.
  • ID - The ID attribute is used to apply style settings to specific individual HTML elements.
  • style - The style attribute is used to apply style settings for the specific element the style attribute is included with. An example is" <p style="font: 16pt courier"> - This sets the style or color of the text. This statement starts a paragraph with color, green: <p style="color: green">. The STYLE attribute is common to most HTML elements (See the CSS Properties page).
  • title - Used to give specific elements a title which may appear as a tooltip in some browsers when the mouse is held at or near the element.

HTML Pre Element Contents

The HTML pre element may contain other inline elements except "img", "object", "applet", "big", "small", "sub", sup". "font", and "basefont". HTML inline elements are listed at the HTML Inline Elements.

HTML Pre Element Inside

The HTML pre element can be contained inside the elements "applet", "blockquote", "body", "button", "center", "del", "dd", "div", "fieldset", "form", "iframe", "ins", "li", "map", "noframes", "noscript", "object", "td", and "th".


HTML Pre Element Use Example

The PRE element is handy for showing program code or part of file content as in this example:

<pre>
switch ( )
{
case condition1
	break;
case condition2
   break;
}
</pre>

This is how it looks:

switch ( )
{
case condition1
	break;
case condition2
   break;
}