您的位置:首页 > Web前端 > CSS

在HTML中引入CSS的方法几种方法

2014-05-13 21:03 369 查看
摘自:http://blog.163.com/dingchunkun_2006@126/blog/static/17149215120113223546835/

在HTML中引入CC有好几种方法,按优先级排列分别是:1、行内式,2、嵌入式,3、导入式和链接式
在HTML中引入CSS的方法有以下几种:

1)行内式

比如:

<body>

<h1 style="color:white;background-color:blue">

This is a line of Text.

</h1>

</body>

2)嵌入式

比如:

<head>

<style type="text/css">

h1{

color:white;

background-color:blue

}

</style>

</head>

<body>

<h1>This is a line of Text.</h1>

<h1>This is another line of Text.</h1>

</body>

3)导入式和链接式

先要把CSS的内容写到一个.CSS的文件中

比如:mycss.css

h1{

color:white;background-color:blue

}

导入式写法(注意CSS文件的路径要正确):

<head>

<style type="text/css">

@import"mycss.css";

</style>

</head>

<body>

<h1>This is a line of Text.</h1>

<h1>This is another line of Text.</h1>

</body>

链接式写法(注意CSS文件的路径要正确):

<head>

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

</head>

<body>

<h1>This is a line of Text.</h1>

<h1>This is another line of Text.</h1>

</body>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: