一、行内样式:(内联样式)直接在标签的style属性中书写
/#书写方式#/
<body style="color:red;">
<---举个🌰--->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>行内样式</title>
</head>
<body>
<div style="color: blue; font-size: 20px; background-color: aliceblue; border: 4px double purple;" >我是容器</div>
<div style="color: blue; font-size: 20px; background-color: aliceblue" >我是容器</div>
<p style="color: red; font-size: 10; background-color: aqua">我是段落</p>
<p style="color: red; font-size: 10; background-color: aqua">我是段落</p>
</body>
</html>

一、行内样式
二、页内样式:在本网页的style标签中书写
/#书写方式#/l
<style>
body {
color:red;
}
</style>
<---举个🌰--->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>页内样式</title>
<style>
div {
color: red;
}
p {
color: blue;
}
</style>
</head>
<body>
<div>我是容器</div>
<p>我是段落</p>
</body>
</html>

二、页内样式
三、外部样式:在单独的CSS文件中书写,然后在网页中用link标签引用
/#通过链接的方式链接到css样式,其中rel="stylesheet" 中的值必须是stylesheet才能用到样式,href="index.css" 中的值为样式文件名#/
<link rel="stylesheet" href="index.css">
<---举个🌰--->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<div>我是容器</div>
<p>我是段落</p>
</body>
</html>
/# css样式文件 index.css #/
div {
color: red;
}
p {
color: blue;
}

三、外部样式
网友评论