Neal <ne*****@spamrc n.com> wrote:
You can observe the behavior and get an idea of what confused you
in the third paragraph at http://users.rcn.com/neal413/test2.html
Oh, I see. It happens in the simplest case too: create a pre element
with long lines and with a visible border set, and Opera will make the
borders correspond to a block that is 100% of the available width
(which is by default somewhat narrower than the window width, due to
body margin and/or padding) whereas the content overflows.
The same happens with a p element (though it takes more work to force
long lines there, but will do the job fine).
1) Is one considered incorrect, or are both fair interpretations
of the recommendation?
If an explicit width has been set, it shall be honored. Content
may overflow, and normally will by default.
But notice the difference in behavior between Opera 7.23 and IE6.
IE stretches the element's boundaries to fit. O allows the text to
spill beyond.
The width defaults to auto, and as far as I can see, the Opera behavior
is then the correct one. The usual quick way to check that Opera is
right and IE is wrong (as usual) is to view the page on Mozilla. Of
course this is not a quite 100% sure way.
2) It would seem the IE performance has the advantage of
retaining intended contrast between text color and background
color.
Such issues should not arise. Why would you set the width narrower
than needed.
I'm not sure what you're saying here. I've set no width for pre or
its container.
Fair point, I had guessed that you had set a width, and I didn't
realize the impact of the default width.
It seems that adding
pre { display: table-cell; }
fixes this, since it makes the width "as wide as needed". IE does not
understand it, so you get the original incorrect behavior, which is
close to what was wanted here. :-)
3) Obviously, unless one is presenting ASCII art or other
width-dependent content, the line length must be considered to
prevent unnecessary horizontal scrolling.
Sorry, I understand all the words but not the idea in the
statement.
The example cited above should make this clear.
Not quite. Your example has some XML markup (specifically, fragment of
XHTML 1.0 markup) there. Since in XML, whitespace is generally not
honored the way it is inside <pre> elements, you don't need <pre> here
(the same way you would, more or less, need <pre> for presenting
FORTRAN or Python code). You might still use <pre> as a practical
solution. Besides, we have the nasty problem that doctype sniffers are
known to violate specifications by regarding white space as significant
between the quoted strings in a doctype declaration, if memory serves
me right.
Anyway, for XML, HTML, etc. markup I would normally use
<div><code class="...">... </code></div>
unless I wish to preformat it for explanatory purposes. But then one
needs to be cautious with strings that must not be broken, which in
practice implies need for nonstandard <nobr> markup. So in the end,
<pre> might be the least of evils.
...In that case you might consider writing a
program that generates markup where each line is inside a <div>
element...
My head aches just thinking about that...
Oh, that shouldn't be two difficult. The real question is whether you
should write it as a Perl one-liner or a Perl two-liner. :-) Seriously,
writing such markup by hand would be very awkward, but when generated
programmaticall y, you would basically need to just look at leading
whitespace on each line.
--
Yucca,
http://www.cs.tut.fi/~jkorpela/