使用鏈接外部樣式文件方式:定義一個獨立的css文件,添加樣式,注意不要在寫style
在需要的html中鏈接指定css文件,在head標簽中加入link標簽
屬性:href:鏈接css文件路徑,type:文件類型,rel:和當前文件的關系
需獨立創建一個css文件
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>使用鏈接外部樣式文件方式</title> <!--使用鏈接外部樣式文件方式:定義一個獨立的css文件,添加樣式,注意不要在寫style 在需要的html中鏈接指定css文件,在head標簽中加入link標簽 屬性:href:鏈接css文件路徑,type:文件類型,rel:和當前文件的關系--> <link href="Style.css" type="text/css" rel="stylesheet"/> </head> <body> <p>功夫瑜伽一</p> <p>功夫瑜伽二</p> <p>功夫瑜伽三</p> <div>成龍</div> <br> <div>高圓圓</div> </body> </html>
css代碼
p{ font-family: "黑體"; font-size: 20; color: blueviolet; text-align: center; /*居中顯示*/ } div{ color: blue; text-decoration: underline; /*下划線*/ }