<!DOCTYPE html> <!-- xml  -->
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>php 中文网--视频教程</title>
	<link rel="stylesheet" type="text/css" href="static/style.css">
	<link rel="stylesheet" type="text/css" href="">
	<style type="text/css">
		body {}
		#box{ width:100px;height: 100px; background: pink;}
		.main{ width:100px;height: 100px; background: green;}
	</style>
</head>
<body >
	<img src="">
	<a href="https://www.baidu.com">百度</a>
	<a href="http://www.php.cn">php中文网</a>
	<a href=""></a>
	<div id="box">123</div>
	<div class="main"></div>
</body>
</html>点击 "运行实例" 按钮查看在线实例
(1)通过标签名称设置:body {}
(2)通过id属性设置:#box{ width:100px;height: 100px; background: pink;}
(3)通过class属性设置 : .main{ width:100px;height: 100px; background: green;}
总结:通过标签的属性设置,可以把包含在body元素内的所有元素自动获取这些样式。
通过id属性设置就是把这个唯一标识的元素获取独一无二的样式。
通过class属性设置,可以把相同class属性的元素组设置同一个样式。
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号