我正在学习CSS,似乎在使用外部样式表时遇到困难。这是我的样式表上名为“ page_style.css”的代码:
p{
color:#383838
font-family:tahoma
}
h1
{
color: #00A300
font-family:david
}
h2
{
color:pink
text-align:center
font-family:arial
}
这是我的HTML页面上的代码:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="F:\Projects\Programming\CSS\In CSS\Try and Fun\Level 1\page_style.css">
</head>
<body>
<h1>This is a big text</h1>
<h2>This is a smaller text</h2>
<p>This is a paragraph</p>
</body>
</html>
我曾尝试在href中而不是整个链接中写入“ page_style.css”,但它也无济于事。尝试更改“斜线”('/'与'\')的方向,但也无济于事。
您的问题缺少CSS中的分号:
p{
color:#383838;
font-family:tahoma;
}
h1{
color: #00A300;
font-family:david;
}
h2{
color:pink;
text-align:center;
font-family:arial;
}
除非您使用file:///
协议:,否则浏览器不会读取完整的文件路径file:///F:\Projects\Programming\CSS\In CSS\Try and Fun\Level 1\page_style.css
。但是某些浏览器不会从http协议跨出文件协议。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="page_style.css">
</head>
<body>
<h1>This is a big text</h1>
<h2>This is a smaller text</h2>
<p>This is a paragraph</p>
</body>
</html>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句