Home > Article > Web Front-end > In what area of the document does the css stylesheet reside?
The css style sheet resides in the "head" area of the document. Because if the CSS is placed at the bottom, the page can be rendered gradually, but after the CSS is downloaded and parsed, the text and images that have been rendered will need to be redrawn according to the new style, which is a bad user experience.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css style sheets reside in the head at the top of the HTML document.
#why?
<link rel="stylesheet" href="home.css">
The href (HyperText reference) attribute in the link tag represents a hypertext reference. When CSS uses href reference, the browser will recognize it The document is CSS and is downloaded in parallel. It will not stop loading the current document. When loading HTML to generate a DOM tree, the DOM tree can be rendered at the same time. This can prevent flickers, white screens or confusing layouts.
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.
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, and then Text appears first, images appear last, 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.
Put the CSS at the bottom, and the page can be rendered gradually. However, after the CSS is downloaded and parsed, the text and images that have been rendered need to be redrawn according to the new style. This is a bad user experience. experience.
(Learning video sharing: css video tutorial)
The above is the detailed content of In what area of the document does the css stylesheet reside?. For more information, please follow other related articles on the PHP Chinese website!