HTML初识:
- HTML是一种描述网页的超文本标记语言(Hyper Text Markup Language)
- HTML不是编程语言,而是一种标记语言
- 主要是用一对“<”“>”组成的标签描述网页
- HTML文档也被称为网页
基本标签:
<h> | 标题 |
---|---|
<p> | 段落 |
<a href="www.baidu.com"> | 链接 |
<img src="xxxx"> | 图像 |
<hr/> | 水平线 |
<br/> | 折行 |
<!--这是个注释--> | 注释 |
<center> | 定义居中文本 |
<s> | 定义删除线文本 |
<u> | 定义下划线文本 |
… | … |
不要忘记结束标签
- 大多数标签都要以</这个标签>闭合,这个结束标签不能省略
- 也有些标签是空的HTML元素,没有内容的 HTML 元素被称为空元素,空元素是在开始标签中关闭的,如上表中
<br/>
和<hr/>
HTML表格:
表格由 <table>
标签来定义。每个表格均有若干行(由 <tr>
标签定义),每行被分割为若干单元格(由 <td>
标签定义)。字母 td 指表格数据(table data),即数据单元格的内容。数据单元格可以包含文本、图片、列表、段落、表单、水平线、表格等等。
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
**在网页上是这样显示的
row 1, cell 1 | row 1, cell 2 |
---|---|
row 2, cell 1 | row 2, cell 2 |
表格的表头:
表格的表头使用<h1>
标签进行定义,大多数浏览器会把表头显示为粗体居中的文本:
HTML列表:
1,无序列表:
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
浏览器中显示:
- Coffee
- Milk
2,有序列表:
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
浏览器显示:
- Coffee
- Milk
HTML表单:
<form>
用于定义表单;
<input>
元素
<input type="text"> | 文本输入 |
---|---|
<input type="radio"> | 单选按钮 |
<input type=checkbox> | 多选按钮 |
<input type="submit"> | 提交按钮 |
<input type="password"> | 密码字段 |
··· | ··· |
<fieldset>
元素
<!DOCTYPE html>
<html>
<body>
<form action="/demo/demo_form.asp">
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
其他表单元素:
<select> | 下拉列表 |
---|---|
<option> | 待选择的选项 |
<textarea> | 文本域 |
<button> | 按钮 |
<datalist> | 为<input> 规定选项列表 |
HTML示例:
<table border="1" bgcolor="C1FFE4" style="border-collapse:collapse;" >
<tr>
<th colspan="4" bgcolor="019858" >个人信息</th>
</tr>
<tr>
<td >姓名:</td>
<td ><input type="text"></td>
<td rowspan="2">性别:</td>
<td rowspan="2"><select style="width: 200;height: 30">
<option value="--请输入性别--" selected>--请输入性别--</option>
<option value="男" >男</option>
<option value="女">女</option>
</select>
</td>
<tr>
<td>手机号码</td>
<td><input type="text" placeholder="仅允许输入数字"></td>
</tr>
<tr>
<td>政治面貌</td>
<td><select >
<option value="--请输入政治面貌--" selected>
--请输入政治面貌--</option>
<option value="群众">群众</option>
<option value="共青团员">共青团员</option>
<option value="党员">党员</option>
</select></td>
<td>方向:</td>
<td>
<input type="radio" name="a">前端
<input type="radio" name="a" >后台
<input type="radio" name="a">全栈
</td>
</tr>
<tr>
<td>
账号:
</td>
<td><input type="number" ></td>
<td>密码:</td>
<td><input type="password" value="3333333"></td>
</tr>
<tr>
<td>特长:</td>
<td colspan="3"><textarea></textarea> ></td>
</tr>
<tr>
<th colspan="2">
<button>重置</button>
</th>
<th colspan="2">
<button onclick="alert('Hello World!')" >提交</button>
</th>
</tr>
</table>