所有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>