Home>Article>Web Front-end> Why put css at the top
Reason:
The CSS file is placed at the top. On the one hand, the order of placement determines the priority of downloading, and more importantly, the browser rendering mechanism.
In the most ideal situation, we hope that the browser will gradually render the downloaded CSS and gradually display the page to the user. However, in order to avoid re-rendering page elements when styles change, the browser blocks the gradual rendering of content. The browser waits for all styles to be loaded before rendering the page at once.
In this way, if the CSS file is placed at the bottom, the browser prevents the content from being rendered gradually. While the browser is waiting for the last CSS file to be downloaded, a "white screen" appears (white screen when a new connection is opened). , then text, pictures, and styles appear last). This is very serious, because when the network speed is very slow, the CSS download time is relatively long, which naturally brings a "white screen" to the user for a long time, and the user experience is very poor.
Recommended tutorial:css tutorial
The above is the detailed content of Why put css at the top. For more information, please follow other related articles on the PHP Chinese website!