What is the use of the "PRE" tag in (X) HTML

what is the use of the "PRE" tag in (X) HTML

+6
html xhtml tags
source share
4 answers

This is for displaying data / code / art, where you want all your spaces and newlines to appear as is, and you want your columns to line up. So you can do things like this:

+-----+------------------+--------+------------+ | id | session_key | length | expires | +-----+------------------+--------+------------+ | 263 | SNoCeBJsZkUegA7F | 86400 | 1257401198 | | 264 | UoVm3SZRmPHnac4V | 86400 | 1257405561 | | 262 | bjkIOWBhI1qxcrWr | 86400 | 1257401189 | +-----+------------------+--------+------------+ 

without "pre" or "code" or some such, it looks like this:

+ ----- + ------------------ + -------- + ------------ + | id | session_key | length | validity period | + ----- + ------------------ + -------- + ------------ + | 263 | SNoCeBJsZkUegA7F | 86400 | 1257401198 | | 264 | UoVm3SZRmPHnac4V | 86400 | 1257405561 | | 262 | bjkIOWBhI1qxcrWr | 86400 | 1257401189 | + ----- + ------------------ + -------- + ------------ +

+9
source share

Used to demonstrate pre-formatted text where breaks in a new line are important. For example, ascii art ;-) or program code. Well, it's better to use the CODE element for program code.

+1
source share

The PRE element is a text block of characters and is suitable for text that has been formatted for a monospace font.

The PRE tag can be used with the optional WIDTH attribute. The WIDTH attribute determines the maximum number of characters for a string and allows the HTML user agent to select the appropriate font and padding.

Hypertext Markup Language - Specifications 2.0 of W3C

+1
source share

Have you ever watched an article posted on the code project site? If you have not looked at this, http://www.codeproject.com/KB/game/Hangman_game.aspx . From the article, a yellow section or one with a collapse and a code fragment is pre-selected. This helps to save the data as it is written or presented, as it is not distorted.

0
source share

All Articles