介绍
- html 语言由标签和标签属性组成
- 标签内不区分大小写, 通常为小写
- 标签支持嵌套
标签分类
类别 | 属性 | 是否独占一行 | 能否设置宽高 | 示例 |
---|
行内元素 | display: inline | False | 不可设置, 即包含内容的宽高 | a , span , i , label , br |
块元素 | display: block | True | 可设置, 宽默认为父元素的宽 | div , p , h1 ~h6 , ol , ul , li , table , form |
行内块元素 | display: inline-block | False | 可设置 | img , input |
标签详解
html 基础结构
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" href='fav.ico'>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div>
hello world
</div>
</body>
</html>
文本
<a>, <span>, <i>, <label>
<p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>
超链接
- href ~ 超链接地址
- target ~ 打开页面方式
- _blank ~ 新标签打开页面
- _self, _top, _parent ~ 本标签打开页面
- title ~ 鼠标悬停时显示的信息
<a href="" target="_blank" title="ips">超链接文字</a>
表单
- 表单标签相关
- input 配合 label 进行关联
- 选择(单选,多选,下拉框)
<form action="" method>
<div>
<label for="i1">用户名: </label>
<input type="text" id="i1" name="username">
</div>
<div>
<label>密码: <input type="password" name="password"></label>
</div>
<div>
<label for="">性别: </label>
<input type="radio" name="gen" value="male" checked="checked">男
<input type="radio" name="gen" value="female">女
</div>
<div>
<label for="addr">地址</label>
<select name="addr" id="addr">
<option value="bj">---</option>
<option value="bj">北京</option>
<option value="sh" selected>上海</option>
<option value="gz">广州</option>
</select>
</div>
<div>
<label for="">出生日期</label>
<input type="date">
</div>
<div>
<label for="">数字示例</label>
<input type="number">
<label for="">Email</label>
<input type="email">
</div>
<div>
<label for="">爱好: </label>
<input type="checkbox" value="basketball" checked>篮球
<input type="checkbox" value="football">足球
<input type="checkbox" value="pingpangball">乒乓球
</div>
<div>
<label for="">头像: </label>
<input type="file" name="pic" accept="image/*">
</div>
<div>
<textarea name="des" cols="30" rows="10"></textarea>
</div>
<div>
<input type="button" value="普通按钮">
<input type="reset" value="重置">
<input type="submit" value="提交">
</div>
<input type="text" id="i1" name="username" value="Kaiyue">
<input type="text" id="i1" name="username" placeholder="username">
<input type="text" disabled>
<input type="radio" name="gen" value="male" checked="checked">男
</form>
列表
- <li> 表示 list
- <ul> 表示无序列表, <ol> 表示有序列表
- type 列表样式
- 无序列表
- disc 实心圆
- circle 空心圆
- square 实心矩形
- 有序列表
- 数字 1 ~ 9
- 字母 a/A ~ z/Z
- 罗马数字 i/I ~ iii/III
<ul type='circle'>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
<ol type='i'>
<li>1</li>
<li>2</li>
<li>3</li>
</ol>
表格标签
- table: 表格
- thead: 表格头
- tbody: 表格体
- tfoot: 表格底
- tr: 表格行
- th: 表格头(默认加粗居中)
- td: 主体单元格
- rowspan: 合并行(竖着合并)
- colspan: 合并列(横着合并)
<table border="1">
<thead>
<tr>
<th>序号</th>
<th>姓名</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Tim</td>
</tr>
<tr>
<td>2</td>
<td>Tom</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
图片标签
- src: 图片地址
- alt: 加载失败时的提示
- title: 鼠标悬停时的提示
<img src='picPath' alt='errorInfo' title='tips' />
非内容标签
引用 css 和 js
<style type="text/css">
h1 {color:red;}
p {color:blue;}
</style>
<link rel='styleseet' type='text/css' href='css/index.css'>
<script>
yuansuojb=document.getElementById('yuansu');
yuansuojb.onclick=function(){
alert(1);
}
</script>
<script type='text/javascript' src='index.js'></script>
其他标签
特殊符号
内容 | 代码 |
---|
空格 | &nbsp; |
> | &gt; |
< | &lt; |
& | &amp; |
版权 | &copy; |
注册 | &reg; |