[03] html 中引入与使用css

1. 使用style属性

<a style="color: red;"> hello ,there use style attribute</a>

2. link 方式

<link rel="stylesheet" type="text/css"  href="./custom.css" media ='all' />

media:

all : 所有媒体 (常用)

screen: 在屏幕媒体中表现文档时使用(例如计算机)(常用)

print: 打印文档和打印预览(常用)

projection:用于投影媒体,例如数字投影仪

braille: 用于Brailler设备表现文档时使用

embossed: 用于Brailler打印设备打印时使用

handheld: 用于手持设备(如个人数字助理或支持web的蜂窝电话)

3.@import

可以在css文档中引入其他外部样式,例如下面是custom.css文件

@import url(style.css)

body {
    backgorund: black;
}
h1 {
    color: red;
}

使用方式:

1.在css文件中,可以使用多个@import

2.必须放在文件头部

3.可以使用第三方外部样式。url(http://exaple.org/library/layout.css)

 

原文地址:https://www.cnblogs.com/yeziTesting/p/8066347.html