Scott on Writing

Musings on technical writing...

Don't Make Me Use IE

I have been using the Mozilla browser and Mozilla Phoenix/FireBird/FireFox browsers for a while now (as far back as when Mozilla Phoenix 0.4), and have happily cast off Internet Explorer.  Or so I thought.  If you use Mozilla FireFox, take a moment to view my latest MSDN article as linked to by the ASP.NET Dev Center.  Scroll down to a code section.  You'll see that there's no whitespace in the code, just a blurb of text, like:

private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) BindData(); } private void BindData() { OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Northwind.mdb")); const string productSQL = "SELECT ProductName, UnitPrice FROM Products WHERE CategoryID = 1"; OleDbCommand myCommand = new OleDbCommand(productSQL, myConnection); myConnection.Open(); dgProducts.DataSource = myCommand.ExecuteReader(); dgProducts.DataBind(); myConnection.Close(); }

Which, while syntactically correct, is far from readable.  If, however, you visit the same page with IE, the spacing is present.  What gives?  What was especially odd was that if I visited the same page through the MSDN library link FireFox displayed the spacing and line breaks in the code sections.  (This anamoly is a fairly recent one; I'm certain I've used FireFox dozens of times before to read MSDN articles from the Dev Centers without such problems...)

A bit of digging revealed that the Dev Center articles link to an external CSS file that has the following rule:

PRE
{
  background:#EEEEEE;
  margin-top:1em; margin-bottom:1em; margin-left:0px;
  padding:5pt;
  white-space:normal;
word-wrap:break-word; }

The culprit is the italicized white-space attribute.  And I blame IE.  Why?  Well, the W3C defines the whitespace attribute to have three legal values: normal, pre, and nowrap.  For normal, the W3C has this to say (emphasis mine):

This value directs user agents to collapse sequences of whitespace, and break lines as necessary to fill line boxes.

So this is what Mozilla FireFox is doing!  It's collapsing sequences of whitespace - tabs, spaces, and carriage returns.  But why isn't IE 6 doing this?  IE 6 does support the whitespace attribute, but has its own, bastardized version of it.  The normal value for IE 6 does the following:

Lines of text break automatically. Content wraps to the next line if it exceeds the width of the object.

Whoops!  They forgot the collapse sequences of whitespace part!  So this is why IE 6 displays the code sections properly, while Mozilla does not - because Mozilla adheres to the standards and IE does not.  Meh.  Now, why does the Dev Center use this CSS?  I'd wager it's so that very long code blocks to not cause the screen to scroll horizontally (note the word-wrap CSS attribute in the PRE tag definition), and that the designers did not test the layout thoroughly with non-Microsoft browsers.

For those who are wondering why the code sections appear fine in the MSDN library version of the article, it's because a different external CSS file is used, which defines the PRE tag like so:

PRE
{
 background:#EEEEEE;
 margin-top:1em; margin-bottom:1em; margin-left:0px;
 padding:5pt;
}

Namely, it omits the whitespace attribute.

I've emailed my MSDN editors about this snafu, and hopefully they can alert the appropriate MSDN folks so I don't have to switch to IE just to read MSDN articles... :-)

posted on Wednesday, March 31, 2004 2:13 PM

Feedback

# re: Don't Make Me Use IE 4/1/2004 12:14 AM Tosh Meston

Scott, from my experience MSDN does listen to the feedback they get from all of us and will most likely make the change for you. I agree it seems weird to have a white-space:normal rule on a PRE, since if it is a PRE tag you are dealing with, you probably want it to be pre-formatted. But check this out. The W3C spec also says:

"Conforming user agents may ignore the 'white-space' property in author and user style sheets but must specify a value for it in the default style sheet."

My read is that IE is ignoring this rule on a PRE and displaying it as you would expect. I'll give the standard disclaimer here as I am guessing and definitely not speaking for the IE team or MSDN for that matter. Know that your feedback is appreciated and keep it coming.

<The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This comment does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.>

# re: Don't Make Me Use IE 4/1/2004 6:26 AM AndrewSeven

I have long been under the impression that browsers do not treat whitespace properly.

This is why so many HTML designers don't like the VS.Net ( and VI 6) design mode, it adds whitespace between tags.

http://weblogs.asp.net/andrewseven/articles/Ramblings.aspx

# Lazycoder weblog &raquo; MSDN and the code in their articles. 4/14/2004 4:40 PM Pingback/TrackBack

Lazycoder weblog &raquo; MSDN and the code in their articles.

# re: Well, that must have been a restful weekend... 5/3/2004 7:18 PM Visual ActiveKent Sharkey .NET SE 3.11

# re: Don't Make Me Use IE 5/18/2004 10:33 AM Scott Mitchell

As of May 17, 2004 (possibly sooner), this has been fixed! Yippie! I can read the ASP.NET Dev Center articles using FireFox! :-)

# re: Don't Make Me Use IE 8/18/2004 6:30 AM Andrew Donaldson

I'm glad someone else noticed this, as a regular user of MSDN (through google) it was driving me mad.

I wonder if in the mean time a bookmarklet could be made to obliterate this annoyance?

# re: Don't Make Me Use IE 8/18/2004 11:40 AM Mark Heimonen

As of August 18th, this issue still hasen't been fixed. I just sent off a reminder email:

Please see the blog entry "Don't Make Me Use I.E." from "Scott on Writing" for more details on this issue:

http://scottonwriting.net/sowblog/posts/961.aspx

The blog entry and the email were written in March, yet the issue is still not corrected. Why are you overriding the default css style of the "PRE" tag, and ignoring web standards?

Since you have chosen to ignore the standards, the preformatted code on the MSDN website doesn't wrap as it designed to when viewed in Mozilla Firefox. It is a major inconvinience to have to open up Internet Explorer every time I wish to view an MSDN article.

I refuse to use Internet Explorer until the well-known security and usability issues are corrected. In any case, it is irresponsible for a large corporation such as Microsoft to provide documentation which is only viewable in their own proprietary browser.

# Solution for this problem 9/2/2004 7:10 AM woutercx

Solution:

Add the following section to your userContent.css
(C:\Documents and Settings\<username>\Application Data\Mozilla\Firefox\Profiles\<default profilename>\chrome\userContent.css):

pre {
background:#EEEEEE ! important;
margin-top:1em ! important;
margin-bottom:1em ! important;
margin-left:0px ! important;
padding:5pt ! important;
white-space:pre ! important;
}

# re: Don't Make Me Use IE 9/8/2004 5:00 AM Andy

Firstly thanks for that fix it was driving me absolutely nuts.

I have had some correspondence with the MSDN team (feedback submission) on the subject of the treeview that they use on MSDN subscriber downloads defaulting to opening all nodes and sub nodes by default. Do you know of a fix for this one at all? That would make me very happy :-)

# re: Don't Make Me Use IE 9/14/2004 4:53 AM woutercx

Sorry, I can't reproduce, I don't have an MSDN subscription.. Any other site that has the same behaviour?

# A FireFox Friendly MSDN 10/20/2004 3:05 PM Scott on Writing

# re: Don't Make Me Use IE 10/20/2004 11:34 PM Lowell Meyer

I'm the MSDN developer responsible for fixes to things like this on our site, and I just wanted to add here that this has now (to our knowledge) been completely fixed on our site. We fixed it in the dev centers back last April/May; however, the problem has still existed in the library (pages under /library) until just recently. Due to a variety of complications, we haven't been able to fix it until just recently.

That being said, all code samples should work correctly now, in all browsers.

I would like to add that I am a Firefox user at home, and that we were not intentionally breaking any browsers. There were actually (somewhat) good reasons why code samples were set to collapse white space before (in non-IE browsers), but that's a much longer discussion. Anyhow, I'd just like to say that we really do care about making our site work for everyone, and that we really like getting feedback about problems with our site. And, more importantly, we listen to that feedback and try to fix as many problems as we can get to. I'm also all about web standards and good HTML/CSS; it's just a long uphill battle to take millions and millions of existing pages and make them happy.

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<July 2008>
SMTWTFS
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Comment Stats

DayTotal% of Total
Sunday 1896.8%
Monday 39014.0%
Tuesday 46916.8%
Wednesday 51518.5%
Thursday 54419.5%
Friday 50818.2%
Saturday 1706.1%
Total 2785100.0%

Hour1Total% of Total
12:00 AM 682.4%
1:00 AM 712.5%
2:00 AM 632.3%
3:00 AM 752.7%
4:00 AM 572.0%
5:00 AM 1093.9%
6:00 AM 1114.0%
7:00 AM 1615.8%
8:00 AM 1756.3%
9:00 AM 1505.4%
10:00 AM 1736.2%
11:00 AM 1826.5%
12:00 PM 1906.8%
1:00 PM 1766.3%
2:00 PM 1605.7%
3:00 PM 1324.7%
4:00 PM 1124.0%
5:00 PM 983.5%
6:00 PM 913.3%
7:00 PM 993.6%
8:00 PM 853.1%
9:00 PM 802.9%
10:00 PM 833.0%
11:00 PM 843.0%
Total 2785100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.14144
Monday 5.35353
Tuesday 4.35444
Wednesday 7.58644
Thursday 6.87625
Friday 5.45414
Saturday 5.03161
Total 5.802785

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.45109
9:00 AM 6.34279
10:00 AM 6.41250
11:00 AM 4.28184
12:00 PM 6.98342
1:00 PM 2.87112
2:00 PM 5.29222
3:00 PM 8.54299
4:00 PM 3.9190
5:00 PM 5.78156
6:00 PM 4.52113
7:00 PM 9.32177
8:00 PM 9.06154
9:00 PM 5.14113
10:00 PM 6.2381
11:00 PM 4.5732
Total 5.802785

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles