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.
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 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:
<p style="color:red;">abc</p>
Written in the tag at the head of the current page:
<head> <meta charset="UTF-8"> <title>Document</title> <style> p{ text-align: center; } </style> </head>
Written in a separate CSS file, referenced using the tag:
<head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="Untitled-1.css"> </head>
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!