html如何和CSS联系起来

时间:2023-03-09 04:05:43
html如何和CSS联系起来

CSS  《Cascading Style  Sheet》层叠样式表 、级联样式表,用于控制Web页面的外观;

Html中使用CSS下面讲述2种常用方法:

1.连接式:可以实现CSS和Html完全分离,方便维护;

在html文件的<head>标签中添加<link>标签:

<link href="untitled.css" type="text/css" rel="stylesheet">

2.内嵌式:

即:

在html文件的<head>标签中添加:

<style type="text/css">
  .red
 {
    color:#C00;
    font-size:18px;

}

.green
 {
   color:#FC0;

}

.size
 {
 font-size:6px;    

}

#blod

{

font-weight:bold;   

}

#yellow
 {
  color:yellow;    

}

.ff

{

font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;

font-size: 14px;

}

</style>

在html的<body>标签中使用:

<p class="red">class选择器</p>

<p class="green">class选择器</p>