HTML
HTML(HyperText Markup Language):超文本标记语言。
超文本:超越了文本的限制,比普通文本更强大。除了文字信息,还可以定义图片、音频、视频等内容。
标记语言:由标签构成的语言
HTML标签都是预定义好的。例如:使用<a>展示超链接,使用<img>展示图片,<video>展示视频。HTML代码直接在浏览器中运行,HTML标签由浏览器解析。
CSS:层叠样式表,用于控制页面的样式。
HTML结构标签特点
- HTML标签不区分大小写
- HTML标签属性值单双引号都可以
- HTML语法松散
演示
1、标题-排版
<!-- 文档类型为HTML -->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 字符集为UTF-8 -->
<meta charset="UTF-8">
<!-- 设置浏览器兼容性 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标题</title>
</head>
<body>
<!-- img标签:
src:图片资源路径
width:宽度(px:像素;%:相对于父元素的百分比)
height:高度 (px:像素;%:相对于父元素的百分比)
路径书写方式:
绝对路径:
1、绝对磁盘路径:属性-安全-对象名称:C:\Users\admin\Desktop\html\头像\头像1.jpg
<img src="C:\Users\admin\Desktop\html\头像\头像1.jpg" >
2、绝对网络路径
相对路径:
./:当前目录,./可省略
<img src="./头像/头像1.jpg" >
../:上一级目录,不可省略
-->
<img src="https://i2.sinaimg.cn/dy/deco/2012/0613/yocc20120613img01/news_logo.png"
width="100px">新浪>正文
<h1>标题</h1>
<hr>
2023年03月02日 21:50 网站
<hr>
</body>
</html>
2、标题-样式1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标题</title>
<!-- 方式二:内嵌样式 -->
<style>
h1{
color: #3F3F3F;
/* color:red;
color:rgb(255, 0, 0);
color: #3F3F3F; */
}
</style>
<!-- 只针对当前页面有效 -->
<!-- 方式三:外联样式 -->
<!-- <link rel="stylesheet" href="./CSS/news.css"> -->
</head>
<body>
<img src="https://i2.sinaimg.cn/dy/deco/2012/0613/yocc20120613img01/news_logo.png"
width="100px">新浪>正文
<!-- 方式一:行内样式 -->
<!-- <h1 style="color: chocolate;">标题</h1>
只对当前有效
-->
<h1 >标题</h1>
<hr>
2023年03月02日 21:50 网站
<hr>
</body>
</html>
3、标题-样式2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标题</title>
<style>
h1{
color: #3F3F3F;
}
/* 元素选择器 */
/* span{
color: #BEBFC4;
} */
/* 类选择器 */
/* .cls{
color: #BEBFC4;
} */
/* id选择器 */
#time{
color: #BEBFC4;
font-size: 13px;
/* 字体大小 */
}
/* 优先级:id选择器>类选择器>元素选择器 */
</style>
<body>
<img src="https://i2.sinaimg.cn/dy/deco/2012/0613/yocc20120613img01/news_logo.png"
width="100px">新浪>正文
<h1 >标题</h1>
<hr>
<span class="cls" id="time">2023年03月02日 21:50 </span> <span>网站</span>
<hr>
</body>
</html>
4、超链接
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标题</title>
<style>
h1{
color: #4D4F53;
}
#time{
color: #8A8A8A;
font-size: 13px;
}
a{
color: black;
text-decoration: none;
}
</style>
<body>
<img src="https://i2.sinaimg.cn/dy/deco/2012/0613/yocc20120613img01/news_logo.png"
width="100px">
<a href="https://gov.sina.com.cn/" target="_self">新浪</a>>正文
<h1 >标题</h1>
<hr>
<span id="time">2023年03月02日 21:50 </span>
<span> <a href="https://news.cctv.com/2023/03/02/ARTIUCKFf9kE9eXgYE46ugx3230302.shtml"
target="_blank">网站</a></span>
<hr>
</body>
</html>
5、正文-排版
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标题</title>
<style>
h1{
color: #4D4F53;
}
#time{
color: #8A8A8A;
font-size: 13px;
}
a{
color: black;
text-decoration: none;
}
p{
text-indent: 35px;/* 首行缩进 */
line-height: 45px;/* 设置行高 */
}
#plast{
text-align: right;/* 对齐方式 */
color: #4F5155;
}
</style>
<body>
<img src="https://i2.sinaimg.cn/dy/deco/2012/0613/yocc20120613img01/news_logo.png"
width="100px">
<a href="https://gov.sina.com.cn/" target="_self">新浪</a>>正文
<h1 >焦标题</h1>
<hr>
<span id="time">2023年03月02日 21:50 </span>
<span> <a href="https://news.cctv.com/2023/03/02/ARTIUCKFf9kE9eXgYE46ugx3230302.shtml"
target="_blank">网站</a></span>
<hr>
<!-- 正文 -->
<!-- 视频 -->
<video src="./视频/1.mp4" controls width="950px"></video>
<!-- 音频 -->
<!-- <audio src="路径" controls></audio> -->
<p>
<b>连续八年1.3万亿斤,这个沉甸甸的数据是如何取得的呢?
</p><!-- 或者使用strong标签,表示强调,有加粗效果 -->
<p>
人勤春来早,春耕农事忙。立春之后,由南到北,我国春耕春管工作陆续展开,春天的田野处处生机盎然。
</p>
<img src="https://n.sinaimg.cn/spider20230302/652/w950h502/20230302/5faa-c51bf98e99783d765c102a5c0f897b85.jpg" >
<p>今粮食产量提高了1500亿斤。</p>
<img src="https://n.sinaimg.cn/spider20230302/658/w950h508/20230302/29ec-6593cb9d9763862c6fe7948ec8f16c5e.jpg">
<p>是一个了不起的成就。”</p>
<p>把“确保我国粮食安全”放在首位。</p>
<p id="plast">
责任编辑:644 SN242
</p>
<!-- 空格占位符:  -->
</body>
</html>
6、正文-布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>标题</title>
<style>
h1{
color: #4D4F53;
}
#time{
color: #8A8A8A;
font-size: 13px;
}
a{
color: black;
text-decoration: none;
}
p{
text-indent: 35px;
line-height: 45px;
}
#plast{
text-align: right;/* 对齐方式 */
color: #4F5155;
}
#center{
width: 65%;
/* margin: 0% 17.5% 0% 17.5%; *//* 外边距:上、右、下、左 */
margin: 0 auto;/* 居中 */
}
</style>
<body>
<div id="center">
<img src="https://i2.sinaimg.cn/dy/deco/2012/0613/yocc20120613img01/news_logo.png" width="100px">
<a href="https://gov.sina.com.cn/" target="_self">新浪</a>>正文
<h1 >标题</h1>
<hr>
<span id="time">2023年03月02日 21:50 </span>
<span> <a href="https://news.cctv.com/2023/03/02/ARTIUCKFf9kE9eXgYE46ugx3230302.shtml" target="_blank">网站</a></span>
<hr>
<video src="./视频/1.mp4" controls width="950px"></video>
<p>
<b>连续八年1.3万亿斤,这个沉甸甸的数据是如何取得的呢?
</p>
<p>
人勤春来早,春耕农事忙。立春之后,由南到北,我国春耕春管工作陆续展开,春天的田野处处生机盎然。
</p>
<img src="https://n.sinaimg.cn/spider20230302/652/w950h502/20230302/5faa-c51bf98e99783d765c102a5c0f897b85.jpg" >
<p>从十年前的约12200亿斤到2022年的约13700亿斤,粮食产量提高了1500亿斤。</p>
<img src="https://n.sinaimg.cn/spider20230302/658/w950h508/20230302/29ec-6593cb9d9763862c6fe7948ec8f16c5e.jpg">
<p>是一个了不起的成就。”</p>
<p>2013年12月把“确保我国粮食安全”放在首位。</p>
<p id="plast">
责任编辑:464 SN242
</p>
</div>
</body>
</html>
7、表格-标签
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<table border="lpx" cellspacing="0" width="600px">
<tr>
<th>序号</th>
<th>品牌Logo</th>
<th>品牌名称</th>
<th>企业名称</th>
</tr>
<tr>
<td>1</td>
<td> <img src="img/huawei.jpg" width="100px"> </td>
<td>华为</td>
<td>华为技术有限公司</td>
</tr>
<tr>
<td>2</td>
<td> <img src="img/alibaba.jpg" width="100px"> </td>
<td>阿里</td>
<td>阿里巴巴集团控股有限公司</td>
</tr>
</table>
</body>
</html>
得到
8、表单-标签
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!--
form表单属性:
action:表单提交的URL,向何处提交数据;如果不指定,默认提交到当前页面
method:表单的提交方式
get:在URL后面拼接表单数据,比如username=小明&age=12,URL长度有限制,默认值
post:在消息体(请求体)中传递的,参数大小无限制的
-->
<form action="" method="post">
用户名:<input type="text" name="username">
年龄:<input type="text" name="age">
<input type="submit" value="提交">
</form>
</body>
</html>
得到
9、表单项-标签
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- value:表单项提交的值-->
<form action=""method="post">
姓名:<input type="text"name="name"> <br><br>
密码:<input type="password" name="password"> <br><br>
性别:<label><input type="radio" name="gender" value="1"> 男 </label>
<label><input type="radio" name="gender" value="2">女</label><br><br>
<!-- 单选框需要将name属性设置为一样 -->
<!-- 选中label标签内任何值都可以表示选中 -->
<!-- 无label则必须精确选中按钮,才能选中 -->
爱好:<label><input type="checkbox" name="hobby"value="java"> java </label>
<label><input type="checkbox" name="hobby" value="game"> game </label>
<label><input type="checkbox" name="hobby"value="sing"> sing </label><br><br>
图像:<input type="file" name="image"> <br><br>
生日:<input type="date" name="birthday"> <br><br>
<!-- 年月日 -->
时间:<input type="time" name="time"> <br><br>
<!-- 时间 -->
日期时间:<input type="datetime-local" name="datetime"> <br><br>
<!-- 年月日+时间 -->
邮箱:<input type="email" name="email"> <br><br>
年龄:<input type="number" name="age"> <br><br>
学历:<select name="degree">
<option value="">-----------请选择-----------</option>
<option value="1">大专</option>
<option value="2">本科</option>
<option value="3">硕士</option>
<option value="4">博士</option>
</select> <br><br>
描述:<textarea name="description" cols="30" rows="10"></textarea> <br><br>
<input type="hidden" name="id" value="1">
<!-- 表单常见按钮 -->
<input type="button"value="按钮">
<input type="reset" value="重置">
<input type="submit" value="提交">
<br>
</form>
</body>
</html>
得到