Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the ways to introduce external css

Shulou Source: shulou.com Published: 2022-06-03 05:22:22 10月02日 Update

Editor to share with you what are the methods of introducing external css, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

There are two ways to introduce external css, namely: 1, through the "@ import" instruction, syntax "@ import url (css file path); >"; 2, through the link tag introduction, syntax "".

The operating environment of this tutorial: windows7 system, CSS3&&HTML5 version, Dell G3 computer.

Two ways of introducing CSS

1. Introduce through @ import instruction

The @ import instruction, which is part of the CSS language, is added to a tag in HTML when used.

@ import url (css/styles.css)

2. Introduce through tags (most commonly used)

The difference between the two ways

Tags belong to html tags, and @ import is a way provided by css. Tags can not only introduce css, but also do other things, while @ import can only introduce css

The difference in loading order: when a page is viewed, the css introduced by link is loaded synchronously, while the css referenced by @ import is not loaded until all other elements have been downloaded

Differences in compatibility: @ import is proposed by CSS2.1, so it is only supported above IE5. Lower versions of browsers do not support it, but tags do not have this problem

When you use javascript to control DOM to change styles, you can only use tags, because @ import is not controlled by DOM.

The above is all the contents of this article entitled "what are the ways to introduce external css?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Tags instructions methods methods articles content grammar control support browsing different not much elements compatibility only most commonly used tutorials files more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi Docker Huawei OPPO Reno