通配符选择器可代表给所有的标签添加样式
*{
margin:0px;
Padding:0px;
}
适合class属性值的选择器
.classSelector{
background-color:cyan;
}
适合id属性值的选择器
#idSelector{
background-color:red;
}
单一的标签选择器
span{
background-color:gold;
display:block;
}
mark标签和h5标签同时添加样式
mark,h5{
font-style:italic;
}
所有ul的a标签子元素添加样式
ul a{
text-decoration:none;
}
span标签下的子元素mark标签添加样式,不可越级
span > mark{
color:blue;
}
同级别中,h1标签之后的第一个p标签添加样式
h1 + p{
backgr-color:cyan;
}
同级别中,h1标签下的所有p标签都添加样式
h2 - p{
background-color:purple;
}
带有title属性的img标签添加样式
img[title]{
border-radius:30px;
}
img[title="image"]{
border-radius:50px;
}
img[title*="image"]{
border:2px solid red;
}
img[title$="ge"]{
transform:rotate(30deg);
}
a:link{
font-size:50px;
background-color:white;
}
a:active{
background-color:red;
}
a:hover{
background-color:gold;
font-size:55px;
}
a:visited{
background-color:gold;
}
input:focus{
background-color:cyan;
}
p:first-letter{
font-size:30px;
color:blue;
}
p:first-line{
background-color:gray;
}
article:after{
content:"~~~";
background-color:red;
}
article:before{
content:".";
background-color:blue;
}
h1 - ul{
background-color:red;
}
p:first-of-type{
background-color:red;
}
p:last-of-type{
background-color:blue;
}
p:only-of-type{
color:white;
}
div:nth-child(2){
color:white;
}
div:nth-child(odd){
color:black;
}
div:nth-child(even){
color:black;
}
div:nth-child(3n+1){
color:red;
}
div:nth-child(3n+2){
color:red;
}
div:nth-last-child(3){
color:white;
}
mark:nth-of-type(2){
display:block;
}
mark:nth-last-of-type(2){
display:block;
}
p:first-child{
background-color:green;
}
p:last-child{
background-color:green;
}
:root{
padding:0px;
margin:0px;
}
div:empty{
width:100px;
height:100px;
background-color:black;
box-shadow:10px 10px 10px gray;
}
:target{
font-size:1.2em;
background-color:snow;
}
input{
background-color:red;
}
input:enabled{
background-color:red;
}
input:disabled{
background-color:red;
}
input:checked{
box-shadow:5px 5px 5px gray;
}
:not(span){
display:block;
}
::selector{
color:red;
font-size:1.5em;
}