Dan's Web Tips:Graceful Degradation[<== Previous] | [Up] | [Next ==>]
Italian translation provided by Earth Moon TIP: There's nothing wrong with using all the latest bells and whistles to support snazzy features of newer browsers, but try to do it in a way that still allows users not supporting (or intentionally disabling) these features to access your basic content. Fortunately, this is easy to do on the Web, if you follow the spirit of the languages and protocols instead of fighting it. "Graceful Degradation" is an important principle in Web design. It means that, when you put in features designed to take advantage of the latest and greatest features of newer browsers, you should do it in a way that older browsers, and browsers letting users disable particular features, can "step down" to a method that still allows access to the basic content of the site, though perhaps not as snazzy in appearance.
Nearly every new feature added to the Web has been done in a way that allows graceful
degradation, starting with the addition of the
NOTE: It would have been even more graceful if the
Newer constructs like Here's an example of an applet coded for graceful degradation:
A Java-supporting user will see the result of an applet "WaveEffect", which presumably
would show a graphic with animated wave effects, and provide a way of getting to the linked
URL provided in the "HREF" parameter. But a non-Java user would have no way of seeing what
was supposed to be there, or getting onward into the site if this was the only navigational
technique, except for the alternative content. This content consists of a normal static
In some cases, when there are several different ways of doing the same effect, and the
set of browsers supporting one or another of them is slightly different, you can achieve
the maximum compatibility by having several levels of nested contstructs that can be
gracefully degraded, like an
There are also a few special tags that let you include content that is only used when
specific features are unavailable or disabled. For instance, It takes only a little bit more work to do this correctly, and adds greatly to the accessibility, flexibility, and search-engine indexability of your pages. Gracefully Degrading JavaScript PopupsA common effect used on many pages is a linked document that comes up as a small JavaScript-created popup window. If you use this effect, it should be sparingly if at all, since it can be annoying to many users. However, there are occasions where it's useful, such as in popping up reference material to assist somebody in filling out a Web form, without their having to leave the page with the form (and possibly not be able to get back to it if it expires from their cache, losing the data they've partially entered).
Often, developers will do this with a
Fortunately, there's a better way. Instead of
NOTE: Since writing the above, I've found out that certain old browsers with early
implementations of JavaScript don't support
These techniques can also be used in other instances where you wish a link to execute JavaScript
code, such as a link mimicing the browser's "Back" button with
TIP: Always use a meaningful
By all means, don't use the regrettably rampant technique of making hyperlinks go
to the "dummy" Gracefully Degrading Menu RolloversAnother popular effect is to have a graphical navigation menu do "rollover effects" when the user moves his/her mouse over the items, such as "lighting up" or "pushing down" the button that is in current focus, or showing more information about the currently-selected item to help the user decide whether to follow the link. There are "graceful" and "non-graceful" ways to do this. The "non-graceful" ways can cause the navigation to fail completely for users who don't support (or have disabled) such things as Java, JavaScript, or Shockwave (depending on how the rollover is implemented). On the other hand, a "graceful" implementation leaves the site fully navigable even for "lowest common denominator" browsers, while adding extra enhancements for those who support them. Sample code for a gracefully-degrading rollover effect is below. However, more than learning specific code, you should learn the general attitude behind this and other gracefully-degrading techniques in Web development. That is to use a sound, logical structure with simple, widely-supported HTML constructs, and then add the "bells-and-whistles" as optional add-ons which can be ignored by non-supporting browsers. The contrary attitude, which creates non-accessible sites, is to skip the "sound, logical, simple" stage and implement the desired effects directly in some advanced language (Java, Shockwave, etc.), ending up with code that doesn't even contain a "plain" HTML link that browsers can follow without running the "applet", "script", or "plug-in". Then, if such authors decide as an afterthought that they need to support "plainer" browsers, they end up sticking an ugly set of "alternative" text links below the "fancy" navigation, which wouldn't be necessary if they designed the site in a graceful manner in the first place.
Here's the "graceful" rollover code: (Note: In this example, the "normal" versions of
the navigation buttons should be placed in
Note the " If you're letting some editor or utility program generate the "rollover effects" for you, make sure it's using a gracefully-degrading technique such as this, and make sure you put appropriate ALT attributes in the images (by hand, if necessary, if the program fails to give you a way to do it). Client and Server-Side FormsIf you have a form that does useful things by means of JavaScript functions, it's still possible to allow it to gracefully degrade for users that don't have JavaScript, if you make sure it submits to a server-side form that performs the same functions, though not as efficiently as it can be done at the client side. For instance, a Web page where the user can type in their amount of savings per year and the expected interest or dividend rate yield and find out how much savings they'll have upon retirement can be done with JavaScript -- this produces a rapid computation without requiring anything to be submitted to a server, but doesn't work at all for users with JavaScript disabled. That can easily be remedied by having the submission action (in the absence of JavaScript) go to a server script that performs the same computations. The JavaScript "onsubmit" function can end in "return false" to prevent the server script from activating when it is not needed. If your form is intended to submit to a server, but you still wish to use JavaScript functions also, such as to validate or correct the input before submission, then you should duplicate the same validation and correction steps in the server script so that they aren't skipped if JavaScript is not enabled or available. This is important for security purposes anyway, as a malicious hacker might create a version of your form that skips the JavaScript validation in order to attempt to input bogus data into your program, so it must be prepared to screen out such things. Some people on the newsgroups ask the wrong question, and say "How do I force my form not to appear, or not to submit, for users with JavaScript disabled, because my JavaScript validation is essential to their correct operation?" You can attempt to do this by making the submit button, or the entire form, be output by JavaScript instead of regular HTML, so it doesn't show up at all without client-side scripting. This can easily be defeated by malicious hackers who can view your source and reconstruct a form with a non-JavaScript submission button, but would pose an accessibility problem for more normal users. Better to design your server scripts so that they work well with or without the assistance of JavaScript. MisconceptionsIf you get into HTML discussions on newsgroups, you'll probably see somebody claim that "graceful degradation" really means making sites plain, boring, and "lowest common denominator." This is far from the truth. People who say it either don't truly understand graceful degradation, or are just trying to make cheap shots against the so-called "purists" rather than discuss Web authoring in a rational way. Actually, graceful degradation does not demand that you not use anything fancy or nice-looking, or that you "author for outdated browsers." It simply requires you to understand the structure of all the elements you use, and be aware of and properly use the built-in features that permit the insertion of alternative content that is accessible to users who can't or won't use the fancy stuff. Graceful Degradation vs. Progressive EnhancementThere's been some discussion lately on Web development sites about the distinction in mindset between "graceful degradation" and "progressive enhancement", which are actually pretty similar concepts, but looked at from different directions. Wikipedia has an article on progressive enhancement, and there have been essays on the subject. The basic difference is that in "progressive enhancement" you begin with a simple, logical, compatible set of marked-up content, and then layer enhanced features for modern browsers on top of it, while "graceful degradation" begins with a full-featured, advanced site, full of bells and whistles, and makes sure it also has content that can be accessed if the fancy features don't work for a particular user. By this standard, the mindset I've advocated fits more in PE than GD, though I used the GD terminology because the other term hadn't been invented at the time. At any rate, if done skillfully, thoughtfully, and cluefully, both techniques should result in very similar sites. Hall of ShameMake your site better by looking at other sites that show, by example, what not to do! NOTE: The inclusion of a site in my "Hall of Shame" links should not be construed as any sort of personal attack on the site's creator, who may be a really great person, or even an attack on the linked Web site as a whole, which may be a source of really great information and/or entertainment. Rather, it is simply to highlight specific features (intentional or accidental) of the linked sites which cause problems that could have been avoided by better design. If you find one of your sites is linked here, don't get offended; improve your site so that I'll have to take down the link!
Links
[<== Previous] | [Up] | [Next ==>]
This page was first created 19 Jul 1998, and was last modified 28 Aug 2019.
|