CSS样式写入位置
CSS(Cascading Style Sheets)样式用来控制网页的视觉呈现效果,它可以写在三个位置:
1. 行内样式
- 将样式直接写入HTML元素中,使用
style
属性。 - 例如:
<p style="color: red;">This text is red.</p>
2. 内部样式表
- 在
标签内创建一个
<style></style>
元素,并将样式写在其中。 -
例如:
<code class="html"> <style> p { color: blue; } </style>