这篇文章主要介绍了html中插入CSS的方法,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获。下面让小编带着大家一起了解一下。
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;}
感谢你能够认真阅读完这篇文章,希望小编分享html中插入CSS的方法内容对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,遇到问题就找亿速云,详细的解决方法等着你来学习!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。