1,写在元素标签的style属性中,仅对当前元素有效;
2,写在当前页面头部的标签中,仅对当前页面所有元素有效;
3,写在独立的CSS文件中,对所有引入该文件的页面均有效。
下面我们用例子来一一说明:
写在元素标签的style属性中:
<p style="color:red;">abc</p>
写在当前页面头部的标签中:
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><style>p{text-align: center;}</style>
</head>
写在独立的CSS文件中:
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><link rel="stylesheet" href="Untitled-1.css">
</head>
下面是CSS独立文件中的内容:
p{color: red;
}