所有HTML语言中的标记都是通过不同的CSS选择器进行控制的。用户只需要通过选择器对不同的HTML标签进行控制,并赋予各种样式声明,即可实现各种效果。
标记选择器
<style>
h1{
color:red;
font-size:25px;
}
</style>
类别选择器
<head>
.css{
color:blue;
font-size:25px;
}
</head>
<body>
<p class = "css">
zyy
</p>
</body>
ID选择器
<style type = "text/css">
#my_p{
color:green;
font-size:25px;
}
</style>
</head>
<body>
<p id = "my_p">
学习java
</p>
</body>
属性选择器
<style type = "text/css">
input[type = "text"]{
color: red;
font-size = 39px;
}
</style>
</head>
<body>
姓名:<input type = "text" name = "name"/>
</body>