CSS style Sheets: links, or embedding

Source: Internet
Author: User
CSS style sheet, is to use <link ...> to call a separate file, or directly with <style>...</style> embedded inside the page good? Or how do these two methods work?

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:
<style type= "Text/css" > <!--body {background:white; color:black;}--</style>
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.
<link rel= "stylesheet" rev= "stylesheet" href= "Http://www.webjx.com/htmldata/2006-08-18/css/style.css" type= " Text/css "media=" All "/>
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 for use with <link>. To add to Ateptsevo's words, the benefits of using <link> are not only to modify the style sheet, but also to speed up the user's browsing. 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 doing Kingsoft online home page (previous version, now can not see), I put all the styles embedded in the page

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 completely adopts the embedding method, the other pages all use the link way. 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: Separate the style and other styles that are responsible for the layout. 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

The above is the CSS style sheet: links, or embedded content, more related articles please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.