Detail CSS style sheet use: Link/embed _css/html

Source: Internet
Author: User

In the W3CN of Ateptsevo, he said:

Reference content
In the past, we used 2 ways of using stylesheets:
Page embedding: The style sheet is written directly in the head area of the page code. Similar to this:

External calling Method: Write the stylesheet in a separate. css file, and then call it in the page head area similar to the following code.

In a web-compliant design, we use external tuning, and the benefits are self-explanatory, and you can change the style of the page without modifying the page to modify only the. css file. If all the pages call the same stylesheet file, then changing the style sheet file will change the style of all the files.

Visible Ateptsevo is highly recommended . To add to Ateptsevo's words, the benefits are not only to modify the stylesheet easily, but also to make the user's browsing speed faster. The first time a user opens a page that links a style sheet, the style sheet is automatically downloaded to the local cache. When the user opens another page, and if the page is linked to the same stylesheet, the associated file is read from the cache, which speeds up the browsing.

But I have also encountered this situation: sometimes encountered the network is not smooth, after the page opened, the linked style sheet did not load successfully. The consequences of this situation, not only the page text color, size and so on style cannot display, more troublesome is likely to cause the entire page layout disorderly set!

For example, once I opened macromedia.com, I met the company network is not smooth, perhaps because there are a lot of people in BT Bar ... The results page appears to look completely like no style sheet, the familiar layout is not visible, all the content from the top down, like using a mobile phone in the site. Although the content can all be seen, but I have to spend some time to familiarize themselves with this new layout, browsing the time there is also a feeling of non-smooth.

In the Golden Mountain Online home page (the previous version, now can not see), I put all the styles into the area of the page. The home page is a Web site with the largest volume of pages, must ensure high reliability. And only for the home page style sheet to take an embedded way, other pages are still used , modify the style without adding too much work.

On weekends to do Amaoagou's homepage, I have further planned the style: layout-related styles: #head, #left之类都嵌入到页面内部, and other styles in a linked way.

To summarize:

* Method One: The homepage is completely embedded method, the other pages are used in the way of linking. Advantages: This will ensure that the home page in the case of poor network conditions can still be displayed correctly. Disadvantage: Modify the style when you need to modify the external style sheet and the first page inline style sheet two places.
* Method Two: Write the style of the layout and other styles separately. Home embedded layout style, link other styles, other pages for both sets of styles are linked. Pros: When you modify a style, it is less than the first workload. When the network is not good, the appearance of the homepage cannot be guaranteed, but at least the layout will not be messy.
* If the production is not a standard page, such as a small project of the company's products, the leader requires table production to ensure that the topic on-line speed. The styles used for each page: links. For only this one page will be used, but will use many times the style: embed. For a style that only one page will be used and used only once: embed or simply write style= "...".

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.