Home>Article>Web Front-end> Where to put css

Where to put css

藏色散人
藏色散人 Original
2021-04-08 09:10:41 7839browse

There are three places where css can be placed, namely: 1. Put it in the style attribute of the element tag, which is only valid for the current element; 2. Put it in the style tag of the head tag at the head of the current page. It is only valid for all elements of the current page; 3. Put it in an independent CSS file and is valid for all pages that introduce the file.

Where to put css

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

Where can I put the css code?

1, written in the style attribute of the element tag, is only valid for the current element;

2, written in the style tag of the head tag at the head of the current page, is only valid for Valid for all elements of the current page;

3, written in a separate CSS file, referenced using the 2cdf5bf648cf2f33323966d7f58a7f3f tag in the head tag; valid for all pages that introduce the file.

Let’s use examples to explain one by one:

Written in the style attribute of the element tag:

abc

Written in the tag at the head of the current page:

  Document  

Written in a separate CSS file, referenced using the 2cdf5bf648cf2f33323966d7f58a7f3f tag:

  Document  

The following is the content of the CSS separate file:

p{ color: red; }

[Recommended learning:css video tutorial

The above is the detailed content of Where to put css. 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