本篇文章帶給大家的內容是關於html怎麼插入CSS? css插入html的四種方法介紹(附程式碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有幫助。
1.註解:
(1).HTML的註解:
(2).CSS的註解:/* *
2.HTML中插入CSS (層疊樣式表)的方法
(1).行內樣式(在標籤後面直接寫樣式)
<!doctype html> <html> <head> <meta charset="utf-8"> <title>行内样式</title> </head> <body> <p style="font-famliy:宋体; text-align:center;font-style:italic; text-transform:uppercase; font-size:22px; text-decoration:underline; font-weight:bold; letter-spacing:13px">html中插入css样式的方法:</br>1 行内样式;2 内部样式; <br/>3 外部样式; 4 导入样式;</p> </body> </html>
(2)嵌入式(將樣式和html語言分開寫)
<!doctype html><html><head> <meta charset="utf-8"> <title>行内样式</title> <style type="text/css"> p{ text-decoration:underline; text-align:center; font-size:26px; font-family:宋体; font-weight:bolder; text-transform:lowercase; letter-spacing:4px; color:pink; background-color:green; } </style></head><body> <p >HTML中插入CSS样式的方法:</br> 1 行内样式;2 内部样式; <br/> 3 外部样式; 4 导入样式; </p></body></html>
3.外部樣式(連結式:將CSS和HTML分開寫入)! ! ! !最常用
first.html
<!doctype html><html><head> <meta charset="utf-8"> <title>行内样式</title> <link href="first.css" type="text/css" rel="stylesheet"></head><body> <p >HTML中插入CSS样式的方法:</br> 1 行内样式;2 内部样式; <br/> 3 外部样式; 4 导入样式; </p></body></html>
first.css
p{ text-decoration:underline;/*加下划线*/ text-transform:lowercase;/*大写字母全部小写*/ text-align:center;/*居中*/ font-size:23px;/*字体大小*/ font-family:黑体;/*设置字体*/ font-style:italic;/*设置字倾斜*/ text-indent:3px;/*设置首行缩进*/ color:red;/*设置字体颜色*/ background-color:#ddd;/*设置背景颜色*/ letter-spacing:4px;}
4.導入式
first.html
<!doctype html><html><head> <meta charset="utf-8"> <title>行内样式</title> <style type="text/css"> @import url(first.css); </style></head><body> <p >HTML中插入CSS样式的方法:</br> 1 行内样式;2 内部样式; <br/> 3 外部样式; 4 导入样式; </p></body></html>
first.css
p{ text-decoration:underline;/*加下划线*/ text-transform:lowercase;/*大写字母全部小写*/ text-align:center;/*居中*/ font-size:33px;/*字体大小*/ font-family:黑体;/*设置字体*/ font-style:italic;/*设置字倾斜*/ text-indent:3px;/*设置首行缩进*/ color:red;/*设置字体颜色*/ background-color:#ddd;/*设置背景颜色*/ letter-spacing:4px;}
相關推薦:
JavaScript動態插入CSS的方法_javascript技巧
以上是html中怎麼插入CSS? css插入html的四種方法介紹(附程式碼)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

Wufoo一直在集成方面非常出色。他們與特定應用程序(例如廣告系列顯示器,MailChimp和Typekit)進行集成,但他們也


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Dreamweaver Mac版
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

SublimeText3 Linux新版
SublimeText3 Linux最新版

WebStorm Mac版
好用的JavaScript開發工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。