CSS四种导入方式和三种基本选择器(id选择器,类选择器,标签选择器)

1.行内样式
在这里插入图片描述
在标签元素中,编写一个style属性,编写样式即可。优先级最高

2.内部样式
在这里插入图片描述
外部样式
分为
链接式
导入式

导入式
在这里插入图片描述

链接式
在这里插入图片描述
推荐使用link标签!

css采用就近原则,优先级:行内样式>内部样式>外部样式
这是导入方式之间的优先级

选择器之间的优先级则是
id选择器 > 类选择器 > 标签选择器

    <style>
        #id01,#id02{
    
    
            color: red;
        }
        .class01{
    
    
            color: yellow;
        }
    </style>
</head>
<body>
<h1>title01</h1>
<h1 id="id01">title02</h1>
<h1 class="class01">title03</h1>
<h1 id="id02" class="class01">title04</h1>
</body>

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_45311187/article/details/112617878