HTML和CSS基础

HTML和CSS

四、HTML结构

<!DOCTYPE html><!-- 文档声明 ,表示这是一个html页面-->
<html>
	<head><!-- 页面的头部 -->
		<title标题</title><!-- 标题 -->
	</head>
	<body><!-- html的主体 -->
		正文部分
	</body>
</html>

五、基本标签

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
	</head>
	<body>
		<!-- html基本标签 -->
		<i>字体倾斜</i><br>
		<b>字体加粗</b><br>
		<u>字体有下划线</u><br>
		<p>段落一</p><br>
		<p>段落二</p><br>
		<hr></hr><br><!-- 分割线 -->
		<h1>最大标题标签</h1><br>
		<h6>最小标题标签</h6><br>
		
		<!-- 修改文字 -->
		<font color="red">设置颜色为红色</font>
		
		<!-- 容器标签 -->
		<div style="background-color: yellow;">emmmmm....</div><!-- 占用的位置是一行 -->
		<span style="background-color: blue;">....emmmmm</span><!-- 内容有多宽就占用多宽的空间距离 -->
	</body>
</html>

六、超链接A标签

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
	</head>
	<body>
	<!-- href : 写的是一个链接地址 -->
	
	<!-- 绝对路径并且在新窗口打开文档 -->
	<a href="https://www.baidu.com/index.php?tn=monline_3_dg" target="_blank">百度一下</a><br>
	
	<!-- 相对路径并且在本窗口打开文档
		./ 本目录
		../上一级目录
	 -->
	<a href="./01_html结构.html" target=""_self"">东京喰种链接</a>
	</body>
</html>

七、图片标签

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
	</head>
	<body>
	<!-- src 属性  : 资源路径(必须有)      jpg,bmp,png,gif
		 alt 属性: 图片资源找不到的时候显示文字提示
		 width 属性:设置图片宽度
		 heigth 属性:设置图片高度(只写一个属性,等比缩放) -->
	
	<img alt="" src="../image/djcz.jpg"><br>
	<img alt="图片不存在" src="../image/ch.jpg"><br>	
	<img alt="" src="../image/timg.gif"><br>
	<img alt="" src="../image/djcz.jpg" width="500px"><br><!-- 等比例缩放 -->
	<img alt="" src="../image/djcz.jpg" width="500px" height="300px">
	</body>
</html>

八、列表标签

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
	</head>
	<body>
	<!-- 无序列表 -->
	<ul>
		<li>银时</li>
		<li>新八</li>
		<li>神乐</li>
	</ul><dr>
	
	<!-- 无序嵌套列表 -->
	<ul>
		<li>芳村</li>
		<li>利世</li>
		<li>分类
			<ul>
				<li>羽赫</li>
				<li>鳞赫</li>
			</ul>
		</li>
	</ul><dr>
	
	<!-- 有序列表 -->
	<ol>
		<li>银时</li>
		<li>新八</li>
		<li>神乐</li>
	</ol><dr>
	
	<!-- 定义列表 -->
	<dl>
		<dt>猪皮</dt>
		<dd>曼基康短腿猫</dd>
		<dt>中分</dt>
		<dd>中华田园猫</dd>
	</dl>
	</body>
</html>

九、表格标签

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
	</head>
	<body>
		<!-- 表格默认是没有边框的,cellspacing将单元格合并 -->
		<table border="1" width="700px" align="center" cellspacing="0px">
			<caption>表格</caption><!-- 定义表格标题 -->
			<tr style="height: 30px"><!-- 代表一行,设置行高 -->
		    	<th></th><!-- 定义表格的表头,效果为加粗居中 -->
		    	<th></th>
		    	<th></th>
		    	<th></th>
		 	</tr>
			<tr style="height: 30px">
				<td></td><!-- 代表一列 -->
				<td rowspan="2"></td><!-- 代表跨行 -->
				<td></td>
			</tr>
			<tr style="height: 30px">
				<td>最后&emsp;一行!</td><!-- 中文空格 -->
				<td></td>
				<td colspan="2"></td><!-- 代表跨列 -->
				<td></td>
			</tr>
			<tr style="height: 30px">
				<td>最后&nbsp;&nbsp;&nbsp;一行!</td><!-- 英文空格 ,三个英文空格等于一个中文空格-->
				<td></td>
				<td></td>
			</tr>
		</table>
	</body>
</html>

十、表单

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
	</head>
	<body>
		<form action="#" method="get">
			<!-- 单行文本输入框 -->
			用户名 : <input type="text"><br>
			<!-- 密码输入框 -->
			密码 : <input type="password"><br>
			<!-- 单选框, name分组,name一样就是一组 -->
			性别 :<input type="radio" name="gender"><input type="radio" name="gender"><br>
			<!-- 复选框  -->
			爱好 :<input type="checkbox">篮球<input type="checkbox">游泳<input type="checkbox">跑步<br>
			<!-- 隐藏控件,中转数据 -->
			<input type="hidden"><br>
			<!-- 文件选择控件 -->
			<input type="file"><br>
			<!-- 图片提交按钮 -->
			<input type="image" scr="../image/djcz.jpg"><br>
			<!-- 下拉框 -->
			省份 <select>
					<option>四川省</option>
					<option>江苏省</option>
					<option>浙江省</option>
			</select>
			城市 <select>
					<option>成都市</option>
					<option>德阳市</option>
					<option>绵阳市</option>
			</select><br>
			<!-- 单行文本输入框 
			Rows: 代表行(多少个字符)
			Cols:代表列(多少个字符)
			-->
			简介 :<textarea rows="10" cols="50"></textarea>
			<!-- 按钮主要是配合js页面脚本代码 -->
			<!-- 普通按钮 -->
			<input type = "button"  value = "来按一下">
			<!-- 重置按钮 -->
			<input type = "reset"  value = "重置表单">
			<!-- 提交按钮 -->
			<input type = "submit"  value = "提交表单">
		</form>
	</body>
</html>

十一、CSS选择器

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
		<style type="text/css">
		/* 	<!-- 通用选择器 -->
			*{
			background-color:blue;
			} */
			/* <!-- 标签选择器 -->
			div{
			background-color:blue;
			} */
			/* <!-- 类选择器 -->
			.a{
			background-color:blue;
			} */
			<!-- id选择器 -->
			/* #b{
			background-color:blue;
			} */ 
		</style>
	</head>
	<body>
		<div class="a">A</div>
		<div id = "b">B</div>
		<div>C</div>
		<div>D</div>
	</body>
</html>

十二、引用、继承与优先级

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
		<link rel="stylesheet" href="../css/css.css">
		<style type="text/css">
			#c{
			color: yellow !important;
			}
		</style>
	</head>
	<body>
	<!-- 就近原则
	!important > 行内样式 > id选择器 > 类选择器 > 标签选择器 -->
		<span style="color: red;">A</span>
		<span>B</span>
		<span style="color: red" id = "c">C</span>
		<span>D</span>
	</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值