"white-space: pre;" and IE

N

noagbodjivictor

I have the following rule:
#textarea { white-space: pre; }

I also have this:
<td id="textarea">
The files in this directory are necessary for GVim Portable to
function.
There is normally no need to directly access or alter any of the
files
within these directories.
</td>

Notice the newlines both at the start and at the end of the text
block. IE just ignores them. FF2 handles them correctly.
 
N

Neredbojias

I have the following rule:
#textarea { white-space: pre; }

I also have this:
<td id="textarea">
The files in this directory are necessary for GVim Portable to
function.
There is normally no need to directly access or alter any of the
files
within these directories.
</td>

Notice the newlines both at the start and at the end of the text
block. IE just ignores them. FF2 handles them correctly.

Okay. What's the point, though?
 
J

Jukka K. Korpela

Scripsit (e-mail address removed):
I have the following rule:
#textarea { white-space: pre; }

As usual, you should have posted the URL, as you will see...

(And you should not use a name like "textarea" - it is just confusing, since
HTML has the said:
I also have this:
<td id="textarea">
The files in this directory are necessary for GVim Portable to
function.
There is normally no need to directly access or alter any of the
files
within these directories.
</td>

Why do you want to use preformatted text here? And rather uneven line
lengths at that! (Hint: Here's _one_ reason why you should have posted a
URL: your (excuse for a) newsreader probably split your lines.)

Preformatted text is _bad_ for normal text.
Notice the newlines both at the start and at the end of the text
block. IE just ignores them. FF2 handles them correctly.

Surprisingly, IE is correct here.
"SGML (see [ISO8879], section 7.6.1) specifies that a line break immediately
following a start tag must be ignored, as must a line break immediately
before an end tag. This applies to all HTML elements without exception."
http://www.w3.org/TR/html401/appendix/notes.html#h-B.3.1

On the other hand, browsers are know to violate such rules, and if IE gets
this right, it probably gets it right by accident only. The safe way is to
avoid such linebreaks, writing

<tagname ...>text
more text
more text
last line</tagname>

My Firefox 2 correctly ignores those line breaks, so what does your document
really contain and which version of Firefox 2 are you using.

Naturally, things change (both in principle and on those browsers) if the
tag <td id="textarea"> is actually followed by a _space_ before the newline.

By the way, which doctype are you using? IE (both 6 and 7) ignores
white-space: pre in Quirks Mode. Hint: If you specify the URL when asking a
question, you won't have to wait for a few rounds of discussion just to make
your problem _analyzable_.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top