首页 > 技术文章 > html文件中引入css代码

wyqiang 2013-07-22 14:10 原文

csstest.html


 <!--doctype:文档类型,用于制定使用哪个dtd(说明当前这个html文件遵循什么版本)-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML4.01 Transitional//EN"
<html>
<head>
<title>css1.html</title>
<!--这个keyword是给搜索引擎用的-->
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<!--告诉浏览器文件是什么编码-->
<meta http-equiv="content-type" content="text/html"; charset="UTF-8">
<!--引入css文件-->
<link rel="stylesheet" type="text/css" href="./csstest.css">

</head>
<body>

<a href="#" >第一个图片</a></br>
<a href="#"><img src="y.jpg"/></a>
<a href="#"><img src="ra.jpg"/></a>
</body>
</html>

 

csstest.css

 


/*.style1就是类选择器*/

.style1{
font-weight:bold;
font-size:20px;
background-color: pink;
}

/*#style2就是一个id选择器*/

#style2{
font-size:30px;
background-color: silver;
}

/*html选择器*/
body{
color: orange;
}

a:link{
color: black;
text-decoration: none;
}
a:hover{
text-decoration: underline;
}
a:visited{
color:red;
}


 

推荐阅读