[whatwg] [HTML5] About the <pre> element

David Bruant bruant at enseirb-matmeca.fr
Tue Nov 24 21:07:50 PST 2009


Hi,

I recently learnt to use the white-space css rule
(http://www.w3.org/TR/CSS2/text.html#white-space-prop) and wondered if
the <pre> element was finally not just a presentational element since
its behavior can be emulated on other elements with a css rule.

On the CSS2 link I provide we can read this :
"The following example show what white space behavior is expected from
the PRE element [...]

pre        { white-space: pre }"
It gives me the impression that the pre element is a caricature of a
presentational element.

Thus, for the computer code use case described in the pre element
subsection, I don't see a reason to use a <pre> element.
Writing the following is semantically sufficient and handles the
presentation as expected :
<code style="white-space:pre;">
#include <stdlib.h>
int main(){
    return EXIT_SUCCESS; // Because we always succeed !
}
</code>

My proposition is to remove the <pre> element since it doesn't have
another semantic than "present the information as I did (white spaces,
line breaks)"

For the ASCII art use case, what is said about "an alternative
description" strongly reminds the alt attribute of the img element.
Perhaps ASCII art should be done inside of an <img> element. The <img>
element is probably the HTML element which has the closest semantic of
the ASCII artist intention.

Any opinion ?

David



More information about the whatwg mailing list