WebReview.com: cross-training for web teams

INSIDE
 Current Issue
 Columns
 Offline
 Archives

TRACKS
 Web Authors
 Designers
 Developers
 Strategists

GUIDES
 Style Sheets
 Web Browsers
 Web Tools
 Ranking System

RESOURCES
 Community
 Forums
 Careers
 Newsletters

ABOUT
 WebReview.com
 Write for Us
 Advertising
 Staff

NETWORK
 WebReview.com
 WebTechniques.com
 Web2001Show.com
 InternetandMobile.com

> Web Browser Guide

Common Browser Implementation Issues

By Steve Franklin
Rank: 2

The following chart discusses many of the common activities that need to be performed across a variety of browsers. For each task, the differences between browsers are outlined, and a "safe approach" is suggested as a way to reconcile differences across the browsers.

This list will grow over time, so feel free to request or suggest additions for common cross-browser issues. Feedback and requests are always welcome, and will be promptly answered and addressed.

The cross-browser functions that are addressed in this article are as follows:

Rendered font sizes

Overview

Text displays differently on various configurations, whether it is due to the operating system, monitor resolution, or the browser.

Browser Support
IE5.x/Win Windows assumes 96 dpi meaning that small font point sizes can be viewed on a number of Windows machines (6pt and 7pt for many fonts). This can create very unreadable fonts for other configurations (namely Mac- or Netscape-rendering).
IE5.x/Mac IE 5 for the Mac now defaults to 96 dpi so be sure to consider this if you are deploying style sheets optimized for the Mac.
NS4.x/Win Netscape typically renders about a point smaller than IE5, meaning that you have to test your pages on both.
NS6.x/Win Netscape lets you override the default dpi value (defaulting to 96 dpi) to tailor display of fonts. NS6 has fixed the problem on NS4.x browsers where fonts showed smaller than IE5 for the same styles.

Recommended Solution

Try to avoid specifying font sizes in pixels (px) or you exclude individuals who like to scale up the font sizes, and you run into some quirks (particularly with Netscape). One solution is to deploy style sheets that are tailored to the specific browser. You can either build the styles dynamically using JavaScript and a sniffer script, or you can use server-side scripts to deploy the correct style sheet. Realize that browsers let you configure the dpi interpretation, so hard-coding style sheets to browsers can be a real problem. Instead, you should design your sites to flexibly accommodate different font interpretations so that your site looks acceptable under different dpi and scaling configurations.


Background audio files

Overview

Playing background audio is not done the same way in all browsers. If you want to stream MIDI or WAV files, you will have to take different steps depending on the browsers you want to support.

Browser Support
IE5.x/Win Supports the <bgsound ...> element to play sounds in the background.
IE5.x/Mac Supports the <bgsound ...> element to play sounds in the background.
NS4.x/Win Supports the <embed ...> element to play sounds in the background.
NS6.x/Win Supports the <embed ...> element to play sounds in the background.

Recommended Solution

First consider whether you want to use background sounds. I have yet to see a good use for it and it can be a very distracting feature. However, if you need the feature, try something like the following (more info in the alt.html FAQ:

  <embed src="file.wav" autostart="true" hidden="true" loop="true">
  <noembed>
    <bgsound src="file.wav" loop="-1">
  </noembed>

You can also accomplish the same functionality with JavaScript after detecting the browser. Different client configurations may not be able to handle the audio format if they do not have a suitable helper application or plug-in that can handle the format.


DOM navigation

Overview

There has been some disagreement in the past regarding the DOM structure and specification. This is being sorted out thanks to standardization by the W3C, but we still see some differences in the way that elements can be located and navigated using the DOM API.

Browser Support
IE5.x/Win Frequently, items are retrieved through document.all, i.e. document.all[elementName]. This is a proprietary approach. Instead use the getElementBy* (and related) calls to access and navigate the DOM tree.
IE5.x/Mac Supports document.getElementsByTagName and document.getElementByID calls as specified in the W3C DOM API.
NS4.x/Win Generally start with document.layers to retrieve named layers within the DOM. Netscape's DOM is not very open and generally you access items through container layers. This is a proprietary approach.
NS6.x/Win Supports document.getElementsByTagName and document.getElementByID calls as specified in the W3C DOM API.

Recommended Solution

Read Effective Cross-Browser Development for some ideas. Now that IE5 and NS6 are converging on a relatively consistent DOM implementation, I would suggest that you focus on correct implementation of the W3C spec, then add tweaking to support non-compliant browsers as necessary and identified by your testing results.


Displaying XML

Overview

XML is an early technology for displaying information in the browsers. Consequently, we run into a problem we've seen before where the major browsers are handling things differently. I'm not convinced that XML is viable for client-rendered display in a cross-browser environment just yet. However, if you are moving in this direction, the following outlines the high-level differences that you should consider.

Browser Support
IE5.x/Win Microsoft has pursued XSLT for formatting display of XML data. CSS support for XML display is poor, as they have focused their efforts on implementation of XSLT support within the MSXML engine. Because Microsoft's CSS/XML support is poor (particularly at the CSS2 level), some common table manipulations cannot be done without XSL, JavaScript or server-side transformations.
IE5.x/Mac IE5.x/Mac is similar to IE5.x/Win in that XSL support exceeds CSS, yet the behavior in the Macintosh implementation is not identical to that of the Windows version (different code base). Expect to test both separately to confirm that your code works properly.
NS4.x/Win No XML support in NS4.x.
NS6.x/Win No XSLT support, although you will find good CSS/XML support for displaying XML data.

Recommended Solution

Unless you have significant control over the configurations of the client browsers that you will be dealing with, server-side transformations will be a much more predictable and tailorable way to bring data to the client.


Event handling

Overview

The two major issues to consider with events are a) accessing event information and b) knowing which events are supported for the various DOM elements. The major discrepancies exist between Microsoft and Netscape. In some cases you can avoid the problem through using a subset of features, but in other cases you will simply have to code in support for multiple browsers.

Browser Support
IE5.x/Win Event.srcElement allows you to find the element receiving the event trigger. Excellent support events associated with most HTML elements as defined in the W3C specification.
IE5.x/Mac As with the Windows version, event.srcElement is supported as is relatively good event support for HTML elements.
NS4.x/Win NS4.x supports event.target to access the element receiving the event trigger. Some event support is missing from a variety of HTML elements (i.e. onClick for the <IMG> tag).
NS6.x/Win Use event.target to access the element receiving the event trigger. Excellent support for events associated with most HTML elements as defined in the W3C specification

Recommended Solution

Try to avoid event code that is critical to your site and only works in version 5+ browsers. Embellishments to your site can be handled through event code without impacting older browsers. Consider passing the event.target (see setupEventObject) to event.srcElement combined with a handleEvent call to create cross-browser event handling code for explicit event triggers.


Document manipulation at run-time

Overview

There are times when you want to provide some dynamic behavior and display in your documents. Unfortunately, many of the browsers do not support DOM manipulation in the same way.

Browser Support
IE5.x/Win Supports DOM 1 manipulation well, and also provides the innerHtml feature for legacy support. Check out DOM1 Comparison for IE5.x DOM support outlined in detail.
IE5.x/Mac Supports DOM 1 manipulation well, although some behavior is different between the Windows and Macintosh versions.
NS4.x/Win Does not support sufficient DOM 1 capability, nor does it support innerHtml. Most behavior is dynamically manipulated through writing to, manipulating and hiding/displaying layers. Dynamic manipulation of page elements (content, style, etc) is minimal. Some simple manipulations (i.e. adding options to a select element) do not force proper resizes, requiring some quirky coding to provide a usable interface. When writing to a layer, you need to open, write and close the document rather than write to it directly.
NS6.x/Win Supports DOM 1 manipulation well, includes some DOM 2 support, and also provides the innerHtml feature for legacy support and compatibility with IE. Check out DOM1 Comparison for NS6.x DOM support outlined in detail.

Recommended Solution

I would suggest that you start writing to the W3C DOM spec as much as possible. Features like innerHtml may disappear much the way that <layer> has vanished from Netscape 6. Test functions and objects before you use them to create robust code. Also, realize that many advanced CSS-P and CSS-2 capabilities are not well supported, so be cautious of using them until the browsers mature further.


Positioning content on the page

Overview

Positioning content on the page is a huge topic that involves CSS-P, layers/divs/iframes, and a discussion of CSS-1/CSS-2 support in the browsers. Although that is outside of the scope of this small section, I will quickly recap iframe, div, visibility, stacking and positioning capabilities of the browsers.

Browser Support
IE5.x/Win Supports iframes and divs. Visibility is controlled using the visibility attribute with values of 'visible' and 'hidden'. Individual elements can be hidden/displayed. z-index is supported for stacking elements on the page.
IE5.x/Mac Supports iframes and divs. Visibility is controlled using the visibility attribute with values of 'visible' and 'hidden'. Individual elements can be hidden/displayed. z-index is supported for stacking elements on the page.
NS4.x/Win Supports layers. Layers are much less constrained in how you can update and position them. They do not resize to fit their content at runtime and require some non-trivial positioning code. Layers are hidden/displayed using the visibility attribute with values of 'show' and 'hide'. Most elements cannot be dynamically hidden/shown. No support for z-index is provided.
NS6.x/Win Supports iframes and divs. Individual elements can be hidden/displayed. z-index can be used to stack items on the page.

Recommended Solution

If you are going to support Netscape 4, you can expect to use a greatly reduced subset of DHTML features. Furthermore, you will probably end up writing three versions of some of your code to handle NS6, IE5.x, and NS4. If you don't need to work with NS4, then your job is much easier and you will be able to get by (in many cases) with one set of code with some small branches to handle browser differences.

The most important thing you can do with content positioning is to test the results on all browsers. Particularly with advanced features, if you do not test, you may not realize that the results simply are unreadable to some of your viewers. Simple mistakes like iframes for NS4.x and poor positioning of layers/divs can only be caught through proper testing of the page.


Passing BODY styles to elements

Overview

Many browsers do not allow child elements to inherit styles as you might expect. The most common mistake is to set styles in the body that you expect to be inherited by all children (tables, cells, headings, etc). The main reason for this problem is not a bug in the code, so much as a quirky decision on the part of the browser vendors to hard-code some user style sheet information in the browser. This means that <td> elements (for example) have pre-defined styles that over-ride those of the body styles. There are some steps you can take to ensure that look-and-feel styles such as font-size and family are propagated throughout your document.

Browser Support
IE5.x/Win Most styles propagate from the <body> element to contained elements, but some bugs are evident. Most notably, IE5.x does not propagate styles to <td> cells properly, so you will need to duplicate style information for these elements. Test style propagation thoroughly as other elements may surprise you (i.e. <select> poplists).
IE5.x/Mac See above
NS4.x/Win Netscape 4.x propagates much less style information from the <body> tag than IE5.x or NS6.x. You will need to test individual elements to confirm behavior, and use a resource such as the CSS Bugs site to identify weaknesses.
NS6.x/Win NS 6.x has much more predictable behavior than NS4.x, and the only major issues that I have run into involve scope of inheritance. Netscape is similar to IE5.x in its behavior with <td> style information received from the body.

Recommended Solution

Set your body style up at the top of your style sheet, and include other elements for which you want the styles to apply. There is little risk in putting too many elements in, as you can over-ride them in subsequent declarations. Something like body,select,td,th,... { ... } will help you to keep look-and-feel consistent across a broader range of browsers.


Mouse-overs

Overview

Mouse-over effects are found on a number of sites. Unfortunately, partial support for CSS means that some effects are not properly supported.

Browser Support
IE5.x/Win Supports a:hover and appropriate onMouse* events for the <a> tag.
IE5.x/Mac Supports a:hover and appropriate onMouse* events for the <a> tag.
NS4.x/Win Does not support a:hover, but supports appropriate onMouse* events for the <a> tag.
NS6.x/Win Supports a:hover and appropriate onMouse* events for the <a> tag.

Recommended Solution

Image-driven mouseovers consume more bandwidth but are more reliable across a broad array of browsers. If you use CSS and the a:hover property, your pages load more quickly but NS4.x will be excluded. For maintainability and bandwidth reasons, I prefer the a:hover approach. The major browsers support the onMouse* events but you will not be able to get the cheap a:hover effect to work on NS4.x.


Padding around elements

Overview

Browser Support
IE5.x/Win No significant problems observed.
IE5.x/Mac No significant problems observed.
NS4.x/Win Some padding bugs must be handled through quirky behavior. The list is exhaustive, but some of the common tricks are: close pack <td> tags around <img> tags, place <form> and </form> tags outside of the <table> tag to avoid a space below your form elements and CSS attributes margin and padding are not fully supported on all elements.
NS6.x/Win No significant problems observed.

Recommended Solution

Be aware of differences by using reference sites such as WebReview's Master Compatibility Chart, an IE5/NS4.x Comparison, CSS Bugs or the CSS Browser Support resource. Some small bugs have been identified with all browsers above, but are outside of the scope of this quick discussion. If you are running into a specific problem, use a resource such as DejaNews to look for answers.


Text Backgrounds Without Tables

Overview

Frequently you will want to highlight blocks of text, and it would be nice to be able to avoid using tables every time. You can use inline styles or place style directives in the head of your document. Unfortunately, these will be interpreted differently by the 4.x generation browsers.

Browser Support
IE5.x/Win Text blocks are filled in properly, with background-color reaching out to the full extent of the text in width and height as a block.
IE5.x/Mac As above.
NS4.x/Win Only specific words of text are highlighted, meaning that you do not get a block of highlighted but an uneven set of highlighted words. This is true for a number of the text containers, i.e. <p> and <div> elements.
NS6.x/Win Behaves properly as with IE5.x above.

Recommended Solution

This is yet another area of CSS where NS4.x will constrain you. If you choose to go with a CSS-driven background approach, your text will look quite bad under Netscape unless it all fits on one line. This, and a number of other common CSS problems can be found in detail at the following site: Browser Comparisons.


Using ActiveX controls

Overview

ActiveX controls are a Microsoft technology for creating reusable components that can be embedded within container applications. Given that they represent Microsoft-proprietary technology, they are only supported in a subset of the browsers.

Browser Support
IE5.x/Win Supported directly within the browser.
IE5.x/Mac One could argue that there is an ActiveX API in IE5.x/Mac, but your standard ActiveX controls will not run on the Mac.
NS4.x/Win 3rd party plug-ins exist to provide an ActiveX container for Netscape (test stability thoroughly as some complaints have been voiced on newsgroups and in discussion forums).
NS6.x/Win 3rd party plug-ins exist to provide an ActiveX container for Netscape (see concerns mentioned above).

Recommended Solution

ActiveX technology greatly reduces the size of the audience that you can reach. Unless you can control the browser audience via a corporate Intranet or something similar, you should probably look for a more open solution. ActiveX is a powerful technology, and can lead to very dangerous bugs, inaccessible functionality on your site, security breaches and more.


Client-side scripting

Overview

Wondering what to use amongst Microsoft's JScript, Netscape's JavaScript, standardized ECMAscript, and Microsoft's VBScript? It is generally clear to work with the most standard specification, now being ECMAscript. Here is a quick recap on browser support for scripting languages.

Browser Support
IE5.x/Win Supports JScript 5.5 (basically JS1.5/ECMA compatible). Also supports VBScript.
IE5.x/Mac Supports JS1.3/ECMA.
NS4.x/Win Supports JS1.2 (NN4) or JS1.3/ECMA (NN4.x).
NS6.x/Win Supports JS1.5/ECMA.

Recommended Solution

Work with core JavaScript capabilities, avoiding any scripting technologies that are not broadly accepted (such as VBScript). Be sure to test and code properly to ensure your JavaScript is cross- platform.


Accessing server-side data

Overview

In some cases, you need to be able to access server data from a database or other similar source. There are a number of ways to do this that are briefly summarized in the following chart.

Browser Support
IE5.x/Win ActiveX with ADO, XML, server-side code, Java applets, plug-ins.
IE5.x/Mac XML, server-side code, Java applets, plug-ins.
NS4.x/Win Server-side code, Java applets, plug-ins.
NS6.x/Win XML, server-side code, Java applets, plug-ins.

Recommended Solution

I suggest staying away from proprietary technologies such as ActiveX, even if you are developing for an Intranet. Technologies and needs change, so an open architecture generally wins out in the long run. Try to do your data access on your middle or server tier, leaving the browser to view generated data. That data can be HTML or XML streamed to the client, simplifying compatibility issues (although XML is still quite young).


Whitespace and line breaks in tables

Overview

When laying out content using tables, you may sometimes find that unexpected spaces and gaps occur in your content. Although this can often be attributed to coding errors, there are a few browser-specific quirks that you should know about.

Browser Support
IE5.x/Win Creates artificial padding if an image is placed within a <td> cell and the </td> is on a new line after the closing tag of the <img> element. Creates whitespace after a closing </form> equivalent to one line's height.
IE5.x/Mac  
NS4.x/Win Creates artificial padding if an image is placed within a <td> cell and the </td> is on a new line after the closing tag of the <img> element. Creates whitespace after a closing </form> equivalent to one line's height. CSS support is poor for a variety of padding, margin and spacing issues associated with tables and table contents. Most table configuration will have to be accomplished directly through tags of the table, tr and td elements.
NS6.x/Win Behavior is very respectable and no major issues have been encountered yet.

Recommended Solution

Some unexpected white space issues can be addressed by tight packing elements, i.e. <td><img ...></td>. You can move the opening and closing tags of a form element outside of the scope of the table to remove the whitespace from the table. You should be wary of using CSS to format display of tables and table contents, particularly if you plan to support NS4.x.


Web Browser Guide Home | Compatibility Chart | Browser Leaders

Feedback and requests are always welcome, and will be promptly answered and addressed.






Current Issue . Columns . Archives . Web Authors . Designers . Developers . Strategists
Style Sheets . Web Browsers . About Us . Write for Us . Advertising . Staff
WebReview.com © 1995-2002 CMP Media LLC. | Privacy Policy