使用ID选择器来声明样式
Use an ID Attribute to Style an Element
和类选择器一样,你也可以使用ID选择器来声明样式。
声明一个叫cat-photo-element
的ID选择器 ,并设置背景色为绿色。:
#cat-photo-element {
background-color: green;
}
注意:在你的 style
元素内部,定义类选择器必须添加 .
为前缀,定义ID选择器必须添加 #
为前缀。
任务:试着给你的表单,添加一个值为 cat-photo-form
的 id 属性,一个绿色的背景。