Four ways to add CSS style sheets to web pages

不言
Release: 2018-05-07 17:59:55
Original
3717 people have browsed it

Four ways to add CSS style sheets to web pages, you can choose your favorite method according to your needs.

1. Use the STYLE attribute: Add the STYLE attribute directly to individual component tags.

The advantage of this usage is that the style can be flexibly applied to each label. But the disadvantage is that there is no "unity" in the entire document.
2. Use the STYLE tag: Write the style rules in thetag.

Copy code

The code is as follows:

Copy after login

For example:

Copy after login

Usually write the entirestructure in thesection of the web page. The advantage of this usage lies in the uniformity of the entire document. As long as there is a declared component, the style rule will be applied. The disadvantage is the lack of flexibility in individual components.
3. Use the LINK tag: Write the style rules in the .css style file, and then introduce it with thetag.
Suppose we save the style rules as an example.css file, we only need to add
to the web page ;
The style specified in the style file can be applied. Usually the LINK tag is written in the

section of the web page. The advantage of this usage is that you can assign several documents to which the same style rules apply to the same style file. The disadvantage is also the lack of flexibility in individual files or components.
4. Use @import to introduce: It is very similar to LINK usage, but must be placed in.

Copy code

The code is as follows:

Copy after login

For example:

Copy after login

It should be noted that the semicolon at the end of the line is absolutely essential! In this way,
@import url(http://yourweb/ example.css);
can also be added to other styles to call.

The above is the detailed content of Four ways to add CSS style sheets to web pages. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!