<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>新建网页</title>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javascript">
</script>
<style type="text/css">
body
{
margin:0/*把margin和padding的值设为0,相当于初始化*/
padding:0
color:#333/*字体颜色的值*/
font:13px Trebuchet MS Lucida Sans Unicode, Arial,sans-serif/*字体的具体设置*/
background:#fff/*背景颜色*/
text-align:center/*居中,这里应该把逗号改为冒号*/
}
h1
{
background:ur1("logo.gif")/*h1背景为logo.gif*/
width:256px
height:25px
overflow:hidden/*隐藏溢出的部分,也就是如何字体超过了所设的256*25,那么就只显示在里面的部分*/
margin:0
}
a
{
text-decoration:none/*超链的没有下划线*/
color:red/*字体为红色*/
}
a:hover
{
colo:green/*当鼠标经过超链时,字体为绿色,hover鼠标经过*/
}
</style>
</head>
<body>
<h1>good</h1>
<a href="#">test<a>
</body>
</html>
楼主看看这个
将 style 标签之间的 css 代码 弄一个 css文件中,注意不要 <style></style>标签进去,
引用外部css文件,在html文件的 head 加上如下代码就可以引用了
<link rel="stylesheet" type="text/css" href="css文件路径/style.css" />这样是不行的。需要用网页调用外部CSS文件。具体的做法就在我写的教程里面就有,摘一段:要让某一个网页调用一个外部CSS文件,你需要在网页的<head>部分插入以下内容:
<head>
<link rel="stylesheet" type="text/css" href="文件位置/你的CSS文件名.css" />
</head>
如果你的css和网页在一个文件夹,href直接添上文件名就可以了。比如说CSS叫做waibu.css,那么代码就是:
<link rel="stylesheet" type="text/css" href="waibu.css">
最后的建议就是可以系统地学习一下CSS,这样应付起来这种问题就游刃有余了。