"; 2. ""."/> "; 2. "".">

Home  >  Article  >  Web Front-end  >  What is the basic way to write css external links?

What is the basic way to write css external links?

青灯夜游
青灯夜游Original
2021-07-21 16:40:0611242browse

Writing method: 1. "3f592fa8dd8e62b0005c9462445b894d"; 2. "11c6b9a105a1d9ddb712796d6febda24@import url("File address");531ac245ce3e4fe3d50054a55f265927".

What is the basic way to write css external links?

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

External style sheets (external link types) must be imported into web documents before they can be recognized and parsed by the browser. External style sheet files can be imported into HTML documents in two ways.

1. Use the 2cdf5bf648cf2f33323966d7f58a7f3f tag to import

Use the 2cdf5bf648cf2f33323966d7f58a7f3f tag to import the external style sheet file:

<link type="text/css" rel="stylesheet" href="css文件地址"/>

For each attribute Description: The

  • href attribute sets the address of the external style sheet file, which can be a relative address or an absolute address.

  • The rel attribute defines the associated document, which here indicates that the associated document is a style sheet.

  • The type attribute defines the type of imported file. Like the style element, text/css indicates a CSS text file.

Generally when defining the 2cdf5bf648cf2f33323966d7f58a7f3f tag, three basic attributes should be defined, among which href is a must-set attribute.

You can also add the title attribute in the link element to set the title of the optional style sheet. That is, when a web document imports multiple style sheets, you can select the style sheet file to be applied through the title attribute value.

Tip: In the Firefox browser, you can select the "View --> Page Style" option in the menu, and then the title attribute value will be displayed in the submenu. Just select a different title attribute value. Selectively apply required style sheet files. IE browser does not support this feature.

In addition, the title attribute is related to the rel attribute. According to the W3C organization's plan, future web documents will use multiple 2cdf5bf648cf2f33323966d7f58a7f3f elements to import different external files, such as style sheet files, script files, and themes. files, and can even include other customized supplementary files. After importing so many files of different types and names, you can use the title attribute to select. At this time, the role of the rel attribute becomes apparent. It can specify the imported file type to be applied when the web page file is initially displayed. Currently, it can only be associated with CSS. Style sheet type.

External styles are the best solution for CSS applications. A style sheet file can be referenced by multiple web pages. At the same time, a web page file can import multiple style sheets by repeatedly using the link element to import different style sheets. document.

2. Use the @import keyword to import

Use the @import keyword in the c9ccee2e6ea535a969eb3f532ad9fe89 tag to import the external style sheet file:

<style type="text/css">
@import url("css文件地址");
</style>

After the @import keyword, use the url() function to include the address of the specific external style sheet file.

Comparison

Comparison of two methods of importing style sheets:

  • ##link is an HTML tag, while @import is CSS which provided.

  • When the page is loaded, the link will be loaded at the same time, and the CSS referenced by @import will wait until the page is loaded before loading.

  • @import can only be recognized by IE 5 or above, and link is an HTML tag, so there is no compatibility issue.

  • #link style styles have a higher weight than @import weights.

It is generally recommended to use link to import style sheets, and @import can be used as a supplementary method.

(Learning video sharing:

css video tutorial)

The above is the detailed content of What is the basic way to write css external links?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is css moduleNext article:what is css module