XML technologies / CSS / CSS Cookbook / Hacks, workarounds and troubleshooting / Preventing page-load flicker in Internet Explorer 5.x for Windows
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
You want to prevent flickering when pages load in Internet Explorer 5.x for Windows before the CSS stylesheet is applied to the page.
Solution
Insert an element link or script as a child of the element head in the web document:
<head>
<title>christopher.org</title>
<link rel="stylesheet" type="text/css" media="print" href="print.css"/>
<style type="text/css" media="screen">@import "advanced.css";</style>
</head>Discussion
When a stylesheet is included in a web page using the method @import, Internet Explorer 5.x for Windows briefly displays the page without stylesheets applied. A fraction of a second later, the browser renders the page again, this time applying the styles.
Inserting an element before the @import-Regel in the page’s head—either link or script—causes the browser to load the styles before actually rendering the page. This prevents the page from first appearing without styles applied.
Strictly speaking, this rendering issue is not a fault of the browser itself: the CSS specification does not say whether this behavior is acceptable, so the browser cannot violate it in this case. You and your users may nevertheless find the flickering disruptive or regard it as a bug, so you should prevent it.
Copyright of the German edition © 2007 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “CSS Kochbuch” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln