css樣式3種寫法備註

三中的使用方法的簡單實例以下:css

行內樣式:html

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 = "width:100px;height:100px;background:red;" ></ div >>
     
</ body >
</ html >

內嵌樣式:spa

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{width:100px;height:100px;background:red;}
</ style >
< div  id = "div" ></ div >>
     
</ body >
</ html >

外部式:code

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文件htm

1
#div{ width : 100px ; height : 100px ; background : red ;}
相關文章
相關標籤/搜索