Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Html calls the method of external css

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "the method of html calling external css". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "the method of html calling external css" can help you solve the problem.

Call method: 1, use the "" statement to call; 2, use the "@ import url (CSS file path address)" statement in the style tag to call.

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

There are two ways for html to call external css

Linked-use tags

Import-use @ import rule tag

1. Linked type

Use tags in tag pairs of web pages to introduce external stylesheet files, and use html rules to introduce external css.

Syntax:

Tags define the relationship between documents and external resources, and the most common use of tags is to link stylesheets.

2. Lead-in

CSS @ import rules, which are used to import style rules from other style sheets. These rules must precede all other types of rules, and @ import cannot be used in a condition group's rules.

Introduce a separate .css file into the HTML file, use the css @ import rule to introduce the external css file, and write it in the markup

Syntax:

@ import url (path address of CSS file)

Compare linking methods and import methods

The linking method (replaced by link) and the import method (replaced by @ import) are both ways to introduce external CSS files. Let's compare these two ways.

Link belongs to HTML. The external file is introduced through the href attribute in the tag, while @ import belongs to CSS, so the import statement should be written in CSS. Note that the import statement should be written at the beginning of the stylesheet, otherwise the external file cannot be imported correctly.

@ import is a new concept in CSS2.1, so external style files cannot be imported correctly if the browser version is older.

When the HTML file is loaded, the file referenced by link will be loaded at the same time, while the file referenced by @ import will not be loaded until the page has been downloaded.

This is the end of the introduction to "html's method of calling external css". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report