Forum Moderators: travelin cat

Message Too Old, No Replies

The <pre> tag with Mac browsers

Question about a potential glitch with Mac browsers & the <pre> tag

         

ryan26

6:24 pm on Dec 8, 2004 (gmt 0)

10+ Year Member



Hopefully somebody can offer some advice on this problem I am having.

I have been using the <pre> tag for quite some time on one of my sites. I will generally place 200-300 words in the <pre> tag and, until now, have noticed no problems with this method at all. The word wrapping works perfectly and everything stays within it's parent <div> without <p> or <br> tags. Cool!

Until now. A colleague has noticed a serious issue while visiting the site from home with a Mac with IE5. The word wrapping is not working at all, leaving us with massive lines of text that create ugly horozontal scrollbars. This happens on Opera & Mozilla too, but is easily fixed with some extra code. I included it below.

pre {
white-space: pre; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* IE 5.5+ */
}

Can anybody shed some light? I'm seeing some other sites mention a <pre> tag bug with the Mac, but I can't find any solid information. My Mac doesn't arrive in the office until tomorrow, either. :(

DerekH

8:19 pm on Dec 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've just produced the following HTML File

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<pre>abc def geh jkl abc def geh jkl
abc def geh jkl abc def geh jkl abc def geh jkl abc def geh jkl
abc def geh jkl abc def geh jkl abc def geh jkl abc
def geh jkl abc def geh jkl abc def geh jkl abc def geh jkl abc def geh jkl abc def geh jkl </pre>
</body>
</html>

In IE 5.2.2 on MacOs 10.3.6, the lines are separated the way they were in the source code...

Sounds like something more complex that your scenario!
DerekH

DerekH

9:27 pm on Dec 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK - I've also tried that HTML in Apple Safari - it's fine, in Netscape 6 - it's fine, and in Opera 7.54 - it's fine too

I wonder if you must be doing something "not quite standard"

DerekH

whoisgregg

9:20 am on Dec 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've confirmed what DerekH posted. There is got to be a specific rule in your CSS that is overriding the pre tag styling.

If the only browser it glitches with is Mac IE 5.2.3, then you'll need to try test pages to isolate which of your existing CSS rules are being "inherited" by the <pre> content in that browser. Look for another pre rule formatted like these, as they will definitely override a general pre { } rule:
div pre { }
.someClass pre { }
#theIDofthepreDiv pre { }