On the external CSS file reference method of CSS programming

Source: Internet
Author: User
Tags html tags relative

CSS external references use external CSS files, the general browser with caching, so users do not have to download this CSS file every time.

External references are efficient for both internal and inline references to save bandwidth.

External references are recommended for use by the consortium.

External referencing CSS is the best way to introduce CSS (you can minimize the amount of code, the most consistent performance is recommended for standard web design. Inline references (used directly in HTML tags) are a quick way (in addition to cascading, I'll introduce cascading in advanced tutorials), But it is not conducive to the future unification of the changes and performance of consistency, so do not advocate the use.

Referencing CSS using the link label

Example

  CSS Code copy content to clipboard

    1. <link rel= "stylesheet" type=" text/css" href= "Http://www.dreamdu.com/style.css"/>

Referencing CSS using @import

Example

  CSS Code copy content to clipboard

    1. <style type="Text/css"> @import URL(http://www.dreamdu.com/style.css);</style>

Relative path and absolute path

You can use a relative or absolute path when loading a file

Absolute path: The full path to the file, the file or directory on the home page, the true path on the hard disk

Http://www.dreamdu.com/html/default.html is absolute path,/html/default.html is also absolute path, C:winntsystem.sys is also absolute path

Relative path: View the path to the document in relation to US

.. /default.html or default.html or. /.. /default.html are all relative paths

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.