批改状态:合格
老师批语:写的还可以,元素三大属性那块可以详细点。
<html><head><meta charset='UTF-8'><title>网页文档标题</title></head><body>网页内容</body></html>
例子:
<h1 id="abc" class="ab" style="color:red;">example</h1>
id 用#来定义样式,例如:
<style>#example{background-color: blue;}</style><div id="example">示例</div>
类class 用.来定义样式,例如:
<style>.example{background-color: blue;}</style><div class="example">示例</div>
元素用标签来定义样式,例如:
<style>p{background-color: red;}</style><p>示例</p>
样式优先级style>id>class ,内联式css样式表,优先级最高的样式表,会覆盖元素,类,id中相同的样式,下例中内联样式的绿色背景色会覆盖id,class中定义的背景色
<style>#example{background-color: blue;}.example{background-color: yellow;}p{background-color: red;}</style><p id="example" class="example" style="background-color: green;">示例</p>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号