三中的使用方法的简单实例如下:
行内样式:
1
2
3
4
5
6
7
8
9
10
11
|
<!doctype html> < html > < head > < meta charset = "UTF-8" > < title >css行内样式</ title > </ head > < body > < div style = "100px;height:100px;background:red;" ></ div >> </ body > </ html > |
内嵌样式:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
!doctype html> < html > < head > < meta charset = "UTF-8" > < title >css内嵌样式</ title > </ head > < body > < style type = "text/css" > #div{100px;height:100px;background:red;} </ style > < div id = "div" ></ div >> </ body > </ html > |
外部式:
1
2
3
4
5
6
7
8
9
10
11
12
|
<!doctype html> < html > < head > < meta charset = "UTF-8" > < title >css内嵌样式</ title > < link rel = "stylesheet" type = "text/css" href = "ccss.css" > </ head > < body > < div id = "div" ></ div >> </ body > </ html > |
css文件
1
|
#div{ width : 100px ; height : 100px ; background : red ;} |