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

Tab Atkins Jr. jackalmage at gmail.com
Tue Nov 24 21:27:20 PST 2009

On Tue, Nov 24, 2009 at 11:07 PM, David Bruant
<bruant at enseirb-matmeca.fr> wrote:
> 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>

This would break as soon as you met a client without CSS support, or
with insufficient CSS support.

> 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)"

That's actually very valuable semantic information.  If whitespace is
important, then the information about it as such should be carried
with the document.  For an extreme example, consider a block of python
or haskell code - without the whitespace, it's simply a non-working

> 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.

ASCII art is indeed semantically closest to <img> (it's just an image
done in a different medium), but there's no way to actually use <img>
as such.  <pre> is the second-closest thing if you're going to include
such a thing.


More information about the whatwg mailing list