css语句写在什么位置

html-css011

css语句写在什么位置,第1张

把css写入html文件内部,称为嵌入式Embedding(也叫内页样式),即在网页上创建嵌入的样式表。内部样式表如下:

<head>

<style type="text/css">

body {background-color: red}

p {margin-left: 20px}

</style>

</head>

当单个文件需要特别样式时,就可以使用内部样式表。可以在 head 部分通过 <style>标签定义内部样式表。

<style>

.china{width:100px}

</style>

写在<style></style>之间,并且放到head标签里

或者引用个css文件

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

也是放到head标签里

Css主要放在<style>标签里面。

示例:

<style type="text/css">

div{width:500pxheight:200pxbackground:#000000}

</style>

特别说明:

另外还有2种Css调用方式,为外部调用及行内调用。