Get the App
SLTechnology News&Howtos  ›  Development  › 

How to introduce js and css files

Shulou Source: shulou.com Published: 2022-06-01 10:33:57 10月03日 Update

Editor to share with you how to introduce js and css files. I hope you will get something after reading this article. Let's discuss it together.

External style sheet

External stylesheets are ideal when styles need to be applied to many pages. With an external stylesheet, you can change the appearance of the entire site by changing a file. Each page uses tags to link to the stylesheet. The tag is in the header (of the document):

one

two

three

The browser reads the style declaration from the file mystyle.css and formats the document based on it.

External style sheets can be edited in any text editor. The file cannot contain any html tags. Stylesheets should be saved with a .css extension.

Multiple style priority

Style sheets allow you to specify style information in a variety of ways. Styles can be specified in a single HTML element, in the header element of the HTML page, or in an external CSS file. You can even reference multiple external stylesheets within the same HTML document.

In general, the priorities are as follows:

Inline style) Inline style > (Internal style) Internal style sheet > (external style) External style sheet > browser default style

The script in HTML must be between the and tag.

Scripts can be placed in the and sections of the HTML page.

External JavaScript

You can also save the script to an external file. External files usually contain code used by multiple web pages.

The file extension of the external JavaScript file is .js.

To use an external file, set the .js file in the "src" attribute of the tag:

one

two

three

four

five

six

You can place the script in or, and the script in the tag runs exactly the same as the externally referenced script.

After reading this article, I believe you have a certain understanding of "how to introduce js and css documents". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Styles files tags scripts documents pages priorities elements multiple situations extensions browsers articles browsing consistency between code information single available through Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Shulou Tech Info Microsoft Shulou Information