Home > Articles > Web Development > HTML/CSS

The Bad Browser: What to Do When Browsers Fail to Play Nice With Your CSS

A Web browser is the essential Internet access tool of the early 21st century, indispensable to business, education, and personal communication. Browsers create a common platform upon which Web-based applications can be built. So what's the problem? In short: Web browsers have been inconsistent in their support for CSS. In this sample chapter, you'll learn the consequence of a browser failure, how current browsers implement CSS, what a layout engine is and how it affects your Web pages, and more.
This chapter is from the book What You'll Learn in This Hour:
  • How web browsers fail to support CSS correctly
  • The consequences of browser failure
  • What the Acid2 test is and what it measures
  • What a layout engine is and how it affects your web page
  • How current browsers implement Cascading Style Sheets
  • How screen readers work with browsers to speak web pages to blind users

CSS rules are always interpreted by web browsers, just as the HTML pages those rules style are interpreted. The HTML and CSS standards give specifics on how browsers should display those rules—but they're not always followed. To design pages with CSS, you not only need to know the standards, as presented in the CSS specification, but also understand how browsers' quirks and flaws will affect your web design results.

The Browser Problem

A web browser is the essential Internet access tool of the early twenty-first century. Browsers are now indispensable to business, education, and personal communication. They create a common platform upon which web-based applications can be built, with an HTML framework driving e-commerce, business-to-business transactions, web-based learning, and online communities. Hundreds of thousands of pages of new information are added to the Web each day. Cascading Style Sheets play a crucial role in this communications medium by not only providing a pleasant visual layer on the surface of these web applications, but also by potentially reshaping the entire user experience.

So what's the problem? In short: web browsers have been inconsistent in their support for CSS.

There are many reasons for this. Some early browsers, such as Netscape 3, were created before the CSS specification was published. Some browsers jumped the gun. Microsoft is notorious for rushing ahead and using draft specifications of standards in their browsers, and then the specifications get changed. And sadly, some browsers are just plain bad. They may seem to function normally, but when it comes to consistent and standardized support for CSS, they fall very short.

The good news is that the problem is being solved. Slowly but surely, each new major browser release is better than the last, and you can get pretty decent CSS implementations from Firefox, Opera, Safari, and other browsers.

How Browsers Deal with CSS

When a browser encounters anything—from CSS rules to HTML, JavaScript to Flash multimedia—it has several choices as to what it can do. If the browser has been programmed to understand the thing it has encountered, it attempts to display it according to the specification. If it has no idea what it has come across, it can ignore it. Both these options can be considered "doing the right thing." Or the browser can do the wrong thing. It can get confused; it can display in some nonstandard way; it can even crash, although that's rare. Doing any of these wrong things, of course, is the least desirable and is at the root of our problem.

Cascading Style Sheets were designed from the start to degrade gracefully. This means that if your CSS rules aren't recognized for some reason, your page is still usable and the content accessible. Because presentation is separated from content, the content should be able to stand on its own, albeit not as beautifully, after the presentation is removed. At least, that's the theory.

In practice it's not nearly as easy as that. To be an effective CSS author, you need to know not only what works in any given browser—or in most or all of them—but also what happens when it doesn't work. Is it as simple as your style not being applied correctly and a bit of decoration being lost, or is it as serious as your entire layout being disrupted and content being lost?

Compliance and Lack Thereof

You need to understand what happens in each case of browser failure to know how to approach each browser. When a browser fails to correctly understand and apply a CSS rule, the browser may just ignore the rule and your design will be fine. Or, because of a browser quirk or bug, it may ignore the rule and your page could become unreadable. As a designer, you need to weigh each style rule carefully and know what effects will result if browsers don't understand and apply it.

In some cases, you may want to use CSS properties that aren't well supported; you may figure that you don't mind some users missing out on a special styling if it improves the site for those users with more advanced browsers. In other cases, you may decide you can't take that chance, and you'll have to make a choice whether to support the broken browsers with workarounds or ignore that audience.

For example, consider a CSS rule that makes the first letter of each section stand out large in a stylized font. This may just be simple decoration, and if the font is normal sized in some browsers, so be it; it may not affect at all the way your page functions.

In other situations, you may be forced to either abandon certain types of style rules that are perfectly valid and useful simply because some major browsers don't support them. An alternative to this approach is to make special modifications, called browser hacks, which allow your style sheets to work despite browser problems. The most common of these is called a filter; a filter prevents certain browsers from reading specific CSS rules that might cause them problems. You'll learn more about browser hacks and filters in Hour 24, "Troubleshooting and Browser Hacks."

To understand how browsers deal with CSS, I've divided them into four categories: ancient browsers, which pre-date the CSS specification and thus ignore it completely; broken browsers, which try to provide CSS functionality but fail horribly in some manner; quirky browsers, which have generally decent CSS support but a number of "gotchas" where they don't quite measure up; and compliant browsers, which do a good job of presenting CSS as it's meant to be. Each category of browsers treats style sheets differently, and it's important to understand what those differences are and how you can design for those browsers.

Ancient Browsers

Ancient browsers are those that existed before Cascading Style Sheets were even a glimmer in the W3C's collective eye. Netscape 3 is the classic example of an older browser, and it does exactly what it's supposed to do: It ignores CSS entirely. If you use Netscape 3 to visit a web page styled with CSS, the browser doesn't notice a single rule. The style sheet doesn't even load.

This is actually ideal behavior for older browsers; with CSS designed for backwards compatibility, most CSS-based websites should still work, although they may be somewhat boring in appearance. Because Netscape 3 is ignoring all Cascading Style Sheets rules, you know exactly what it will do with them; there's no guesswork necessary on the part of the author. You don't have to do anything special to support these types of browsers, except for testing your designs to see whether they still function without CSS.

Some ancient browsers are:

  • Lynx
  • Mosaic (no longer in widespread use)
  • Netscape 3 (no longer in widespread use)

Broken Browsers

The worst kind of browser is one that is simply broken when it comes to CSS, despite whatever claims the provider makes to standards compliance. A broken browser is one that, when given perfectly legitimate Cascading Style Sheets rules, doesn't present a web surfer with anything useful, but instead displays a mishmash of styles where information gets lost. The difference between an older browser and a broken browser is that older browsers don't try to display CSS, and broken browsers try and fail horribly.

Internet Explorer 3 was the first browser to implement any CSS, but it did an overall bad job at it, based in part on the fact that they coded to a specification that was still being written at the time. When the final version of CSS Level One came out, it was quite different from Internet Explorer 3's attempt to implement CSS support.

Fortunately, Internet Explorer 3 has almost passed into memory, replaced by newer versions of Internet Explorer that are closer to the CSS specification, meaning that the buggy CSS implementation in Internet Explorer 3 really isn't a factor in current CSS usage.

To account for the broken browsers out there, it's necessary to understand how they're broken and what happens when you give each browser some CSS rules that it doesn't understand. In some cases, the broken browser just ignores your CSS, as is the case with a limited or older browser; in others, it may do something horribly wrong.

There are two approaches to dealing with broken browsers. First, you can code around the problems by using a filter or other browser hack to prevent the browser from mangling your page. And second, for some browsers that are just so old that few people use them any more, you could just no longer support those browsers on your website.

The list of broken browsers includes:

  • Internet Explorer 3 (no longer in widespread use)
  • Netscape 4 (no longer in widespread use)
  • Various minor releases of browsers that had serious bugs, and thus are no longer available

Quirky Browsers

Between the downright broken browsers and the compliant ones is a category of web browsers that have the best intentions, but just don't get it quite right. These browsers are generally compliant but have serious problems that come out when you start doing complex styles—for example, when using CSS to lay out a web page. We'll call these quirky browsers.

Unlike broken browsers, these are still in use, especially Internet Explorer versions 5 through 6. This means that as a web designer you can't just ignore them, nor can you simply lay the blame on the programmers who created the browser. It's your website (or your employer's, or your client's), and you need to take responsibility for how it appears in common browsers.

The way to deal with these browsers is to understand their quirks and bugs and work around them. One strategy is to use only "safe" CSS code in your designs, even if that limits the effects you can produce in more fully compliant browsers. Another method for dealing with a quirky browser is to use filters and other browser hacks to tailor the style rules given to that browser; techniques of this sort are described in Hour 24.

Some browsers with quirks include:

  • Internet Explorer 6, 5.5, and 5
  • Internet Explorer for Mac (no longer in widespread use)
  • Opera 5 and 6 (no longer in widespread use)
  • Netscape 6 (no longer in widespread use)

Compliant Browsers

A compliant browser is one that follows the CSS and HTML specifications to the letter. Well, that's not really true—as of early 2006, no browser can legitimately claim 100% standards compliance. However, there are browsers that get very close, to the extent that they can be treated as basically compliant. This is the category we'll call compliant browsers, although if you want to be pedantic, you can think of this as the "almost compliant" group instead.

When designing for compliant browsers, you don't have to do anything particularly special other than follow the CSS 2.1 specification. The selectors and properties you'll learn in later chapters of this book will work as described; text styling and even complex layouts don't present any major obstacles. You won't need to use filters or other browser hacks to deal with compliant browsers.

However, you need to keep in mind that not all browsers out there are compliant. The quirky browsers, in particular, are still around and may require special attention, even if the compliant browsers are going to be well behaved.

The following are generally compliant browsers:

  • Firefox 1.5
  • iCab
  • Konqueror
  • Mozilla 1.7
  • Opera 8.5
  • Safari 1.3 and 2

Web Standards and the Acid2 Test

As you learned in Hour 1, "Understanding CSS," the CSS language is defined by the Cascading Style Sheets Level 1 and Level 2 recommendations from the World Wide Web Consortium, and updated by CSS 2.1. These recommendations function as standards for the CSS language.

Standards are a good thing for developers; the more the browsers support the standards, the easier it is for us to create expressive and attractive designs in CSS and know they'll work reliably. Increased support from standards, the browser makers, the web developer community, and the web software manufacturers will only make our jobs easier.

One group of web designers decided to take their support for standards public and founded the Web Standards Project to encourage browser makers to adhere closely to the CSS recommendations and other web standards. In addition to their advocacy work, the Web Standards Project site contains useful FAQs and links on standards support. Their URL is http://www.webstandards.org/.

In 2005, the Web Standards Project developed the Acid2 test. Acid2 is a web page created with some rather complex CSS rules that hit key parts of the CSS and HTML specifications. If a browser successfully interprets and displays the CSS rules according to the standards, a happy face is displayed. Figure 3.1 is the reference picture showing how a compliant browser should display Acid2.

03fig01.jpg

Figure 3.1 How the Acid2 test is supposed to look; shown in Safari 2.

Figure 3.2, on the other hand, is an example of a failed test. Internet Explorer 6 doesn't display the happy face according to the specifications.

03fig02.jpg

Figure 3.2 Internet Explorer 6 quite clearly fails the Acid2 test.

As of early 2006, four browsers had passed the Acid2 test; in order: Safari, iCab, Konqueror, and Opera. Acid2 isn't the ultimate test of CSS support—it's possible to pass Acid2 and still have serious CSS bugs or quirks—but it is an important benchmark for measuring progress toward standards compliance.

Browser Compatibility Charts

A browser compatibility chart is an invaluable resource for anyone doing serious CSS work. What is it? A compatibility chart lists every CSS property in a matrix, cross-referenced with a number of different browsers (including various version numbers and platforms). For example, if you want to know whether version 5.5 of the Internet Explorer browser supports the text-transform property, you can consult a compatibility chart. For each property you look up, you'll see whether or not it's supported by the browser, and if there are any special notes or known bugs in the implementation.

There are several sources of CSS browser compatibility charts; one that's particularly nice to use is David Hammond's chart at http://www.webdevout.net/. Bookmark that site and refer to it when testing your CSS-based designs. Brian Wilson's Index DOT css site at http://www.blooberry.com/indexdot/css/ hasn't been updated for several years, but it's still useful if you need to dig back through history for information on older browsers.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020